Reputation: 61
I used modal instance to open a modal with controller which is defined inside the main controller.
var helloControllers = angular.module('helloControllers', []);
helloControllers.controller('ScheduleUpdateCtrl', ['$scope','$routeParams', '$http','$modal',
function($scope,$routeParams, $http, $modal) {
/*--------lines of code-------------*/
$scope.setting=function(){
var modalInstance = $modal.open({
templateUrl: 'ScheduleSettings/ScheduleSettings.html',
controller: ScheduleSettingsCtrl,
/*--- lines of code--------------*/
var ScheduleSettingsCtrl = function ($scope, $modalInstance,$filter,scheduleId,scheduleName,grouplist,devicelist,secondtime)
Now I need to use a filter for a listbox to exclude the items which is contained in another listbox
<select size=9 ng-model="deviceselected" ng-options="de as de.DEVICE_NAME for de in deviceAllList|exclude"></select>
<select size=9 ng-model="deviceavailable" ng-options="de as de.DEVICE_NAME for de in deviceList"></select>
Something like:
filter('exclude',function(){
return function(array){
var out=[];
alert('!');
for(var i=0;i<array.length;i++){
alert(array[i].GROUP_ID);
if(groupList.map(function(e) { return e.GROUP_NAME; }).indexOf(array[i].GROUP_NAME)==-1)
out.push(array[i]);
}
return out;
};
But I don't know where to put these lines or use it in html. I'm clueless so helps with demo would be much appreciated.
More details
More questions: Where should the filter definition belong to? I tried
helloControllers.filter('exclude',function(){
How to test if the filter call is valid/undefined? I got this error.
Error: [$injector:unpr] Unknown provider: excludeFilterFilterProvider <- excludeFilterFilter
Upvotes: 1
Views: 682
Reputation: 4274
Try this: It is as simple as we are using filter in some other html element.Same way with |
you can apply filter here in ng-options
<select size=9 ng-model="deviceselected" ng-options="de as de.DEVICE_NAME for de in deviceAllList | exclude"></select>
<select size=9 ng-model="deviceavailable" ng-options="de as de.DEVICE_NAME for de in deviceList | exclude"></select>
Upvotes: 2