我正在尝试根据布尔属性的值过滤一些列表项,但是无论我做什么,总会显示整个列表。我尝试过的一些东西已经坏掉了,什么也没显示,但这既不存在也不存在。我无法按需进行过滤:
$scope.attendees = [
{"firstname":"Steve", "lastname":"Jobs", "arrived":true, "id":1}
,{"firstname":"Michelle", "lastname":"Jobs", "arrived":false, "id":2}
,{"firstname":"Adam", "lastname":"Smith", "arrived":true, "id":3}
,{"firstname":"Megan", "lastname":"Smith", "arrived":false, "id":4}
,{"firstname":"Dylan", "lastname":"Smith", "arrived":false, "id":5}
,{"firstname":"Ethan", "lastname":"Smith", "arrived":false, "id":6}
];
使用以下ng-repeat过滤:
<ul>
<li ng-repeat="person in attendees track by person.id | filter:arrived:'false'">
{{person.lastname}}, {{person.firstname}}
</li>
</ul>
我觉得我已经尝试了所有可以找到引用的排列,其中大部分来自各种StackOverflow搜索结果:
filter:'arrived'
filter:arrived
filter:'person.arrived'
filter:person.arrived
filter:{arrived:true}
filter:{arrived:'true'}
filter:{person.arrived:true}
filter:{person.arrived:'true'}
我也尝试过创建自定义过滤器功能:
$scope.isArrived = function(item) {
return item.arrived;
};
并因此应用:
filter:isArrived
filter:'isArrived'
filter:{isArrived(person)}
filter:isArrived(person)
filter:'isArrived(person)'
这些似乎都不起作用。我想念什么?
trackBy: ..
像其他所有东西一样使用并正常运行。