如何通过复选框过滤多个值(OR操作)

前端之家收集整理的这篇文章主要介绍了如何通过复选框过滤多个值(OR操作)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何使用复选框在angularJS中过滤多个值(OR操作) @H_301_1@<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/

使用过滤功能

视图:

@H_301_1@<ul ng-repeat="movie in movies | filter: showMovie"> <li>{{movie.name}}</li> </ul>

控制器:

@H_301_1@$scope.showMovie = function(movie){ return movie.genre === $scope.Filter.Comedy || movie.genre === $scope.Filter.Drama || movie.genre === $scope.Filter.Action; };

Fiddle

原文链接:https://www.f2er.com/angularjs/144328.html

猜你在找的Angularjs相关文章