我已应用自定义过滤器来检查属于已检查哪个组的复选框。
过滤器基本上隐藏了没有选中任何一个的复选框组。
我需要做的是,在选中或取消选中框时重新应用过滤器。 。当所有属于某个组的复选框都未选中时,其他组都会显示出来。我该怎么做呢?
<ul ng-repeat="(key,value) in filtered=(properties | filter:filterByCategory| groupBy: 'name') ">
<li>Group name: <strong>{{ key }}</strong></li>
<div ng-repeat="prop in value">
<label>
<input type="checkbox" ng-model="filter[key][$index]" ng-change="Changed"/>
<span>{{prop.Property}}</span>
</label>
</div>
</ul>
我想我需要这样的东西:
mentioned here与ng-change
。
Plunkr:
尝试:
我尝试将其更改为:
<input type="checkbox" ng-model="filter[key][$index]" ng-change="fireFilter(key)">
和
$scope.fireFilter = function(prop){
console.log("PROP WHEN CALLED" + prop);
$filter('filterByCategory')(prop);
$scope.filter=[];
}
});
但它给我一个错误,上面写着:
Error: [$injector:unpr] http://errors.angularjs.org/1.2.22/$injector/unpr?p0=filterByCategoryFilterProvider%20%3C-%20filterByCategoryFilter
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js:6:450
at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js:36:145
at Object.c [as get] (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js:34:236)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js:36:213
at Object.c [as get] (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js:34:236)
at $get (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js:124:238)
at k.$scope.fireFilter (file:///C:/Users/dev4/Desktop/Grouping/js/scipt.js:40:2)
at db.functionCall (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js:176:387)
at k.$get.k.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js:112:15)