过滤的角1.2纳克重复使用"跟踪由"由布尔属性
我试图筛选基于一个布尔值,属性值一些列表项,但始终显示,无论我做什么,整个列表。少数人的我试过的东西已经让破,没有什么显示,但那是不伦不类。根据需要,我不能让我的工作过滤:
I'm trying to filter some list items based on the value of a boolean property, but no matter what I do the entire list is always displayed. A few of the the things I've tried have been so broken that nothing displays, but that's neither here nor there. I can't get my filtering working as desired:
$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-重复过滤:
Using the following ng-repeat filtering:
<ul>
<li ng-repeat="person in attendees track by person.id | filter:arrived:'false'">
{{person.lastname}}, {{person.firstname}}
</li>
</ul>
我觉得我已经想尽了我能找到引用的置换,其中大部分来自于各种计算器的搜索结果:
I feel like I've tried every permutation that I can find referenced, most of which came from various StackOverflow search results:
-
过滤器:到达
-
过滤器:到达
-
过滤器:person.arrived
-
过滤器:person.arrived
-
过滤器:{到达:真正}
-
过滤器:{到达:'真正的'}
-
过滤器:{person.arrived:真正}
-
过滤器:{person.arrived:'真正的'}
filter:'arrived'
filter:arrived
filter:'person.arrived'
filter:person.arrived
filter:{arrived:true}
filter:{arrived:'true'}
filter:{person.arrived:true}
filter:{person.arrived:'true'}
我也尝试创建一个自定义过滤器功能:
I've also tried creating a custom filter function:
$scope.isArrived = function(item) {
return item.arrived;
};
和应用正是如此吧:
-
过滤器:isArrived
-
过滤器:isArrived
-
过滤器:{isArrived(人)}
-
过滤器:isArrived(人)
-
过滤器:isArrived(人)
filter:isArrived
filter:'isArrived'
filter:{isArrived(person)}
filter:isArrived(person)
filter:'isArrived(person)'
这些都不似乎工作。我缺少什么?
None of these seems to work. What am I missing?
下面是一个演示我的问题一个plnkr。
这是需要的轨道是在除权pression的末尾:
The track by needs to be at the end of the expression:
<li ng-repeat="person in attendees | filter: {arrived: false } track by person.id">