我试图过滤一些列表项基于布尔属性的值,但无论我做什么,整个列表总是显示。我试过的一些东西已经被打破,没有什么显示,但这不是在这里也没有。我不能让我的过滤工作按照预期:
$scope.attendees = [ {"firstname":"Steve","lastname":"Jobs","arrived":true,"id":1},{"firstname":"Michelle","arrived":false,"id":2},{"firstname":"Adam","lastname":"Smith","id":3},{"firstname":"Megan","id":4},{"firstname":"Dylan","id":5},{"firstname":"Ethan","id":6} ];
使用以下ng重复过滤:
<ul> <li ng-repeat="person in attendees track by person.id | filter:arrived:'false'"> {{person.lastname}},{{person.firstname}} </li> </ul>
我觉得我已经尝试了每个排列,我可以找到引用,其中大部分来自各种StackOverflow搜索结果:
> 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)’
这些似乎都不起作用。我缺少什么?
轨道需要在表达式的结尾:
<li ng-repeat="person in attendees | filter: {arrived: false } track by person.id">