我只是创建一个自定义过滤器。他们并不难。
模板:angular.module('myFilters', []). filter('bygenre', function() { return function(movies,genres) { var out = []; // Filter logic here, adding matches to the out var. return out; } });
<h1>Movies</h1><div ng-init="movies = [ {title:'Man on the Moon', genre:'action'}, {title:'Meet the Robinsons', genre:'family'}, {title:'Sphere', genre:'action'} ];" /><input type="checkbox" ng-model="genrefilters.action" />Action<br /><input type="checkbox" ng-model="genrefilters.family" />Family<br />{{genrefilters.action}}::{{genrefilters.family}}<ul> <li ng-repeat="movie in movies | bygenre:genrefilters">{{movie.title}}: {{movie.genre}}</li></ul>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)