我使用模态实例打开了一个在主控制器中定义的带有控制器的模态。
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)
现在我需要使用列表框的过滤器来排除包含在另一个列表框中的项目
<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>
类似于:
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;
};
但我不知道把这些行放在哪里,也不知道在html中使用它。我一无所知,所以帮助演示将不胜感激。
更多详细信息
更多问题:过滤器定义应该属于哪里?我试过
helloControllers.filter('exclude',function(){
如何测试筛选器调用是否有效/未定义?我犯了这个错误。
Error: [$injector:unpr] Unknown provider: excludeFilterFilterProvider <- excludeFilterFilter
试试这个:它和我们在其他html元素中使用filter一样简单。与|
相同,您可以在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>