试图为Angular.js过滤角重复
创建过滤器Controller.js示例代码段:
function TitleListCtrl($scope) {
$scope.titles = [
{ "name": "Foobar",
"editions":
[{"print": true,
"ebook": false,
"audio": false }]
},
{ "name": "FooBarBar",
"editions":
[{"print": false,
"ebook": false,
"audio": false }]
}
];}
角HTML:
<ul ng-controller="TitleListCtrl">
<li class="TitleList" ng-repeat="title in titles
| filter:isUpcoming
| orderBy:'date'">{{title.name}}</li>
</ul>
现在,我试图返回只有那些没有活动版本的标题(没有版本数组的成员设置为true)。发现很难找到在线的例子做这样的事情......
$scope.isUpcoming = function(title) {
return title.editions[0] & title.editions[1] & title.editions[2]===false;
};