如何使用Checkbox过滤angularJS中的多个值(或操作)
<ul ng-repeat="movie in movies |filter:Filter.Comedy | filter:Filter.Action | filter:Filter.Drama"> <li>{{movie.name}}</li> </ul> <label>Comedy</label><input type="checkbox" ng-model="Filter.Comedy" ng-true-value="Comedy" data-ng-false-value=''/><br/> <label>Action</label><input type="checkbox" ng-model="Filter.Action" ng-true-value="Action" data-ng-false-value=''/><br/> <label>Drama</label><input type="checkbox" ng-model="Filter.Drama" ng-true-value="Drama" data-ng-false-value=''/>
http://jsfiddle.net/samibel/va2bE/1/
使用过滤器功能:
视图:
<ul ng-repeat="movie in movies | filter: showMovie"> <li>{{movie.name}}</li> </ul>
控制器:
$scope.showMovie = function(movie){ return movie.genre === $scope.Filter.Comedy || movie.genre === $scope.Filter.Drama || movie.genre === $scope.Filter.Action; };
**[Fiddle](http://jsfiddle.net/GruffBunny/utKug/)**