Filtering an Angular 1.2 ng-repeat with "track by" by a boolean property
angularjs, angularjs-ng-repeat
Solution
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">
Problem
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} ]; ``` 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: - `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; }; ``` And applying it thusly: - `filter:isArrived` - `filter:'isArrived'` - `filter:{isArrived(person)}` - `filter:isArrived(person)` - `filter:'isArrived(person)'` None of these seems to work. What am I missing? Here's a plnkr that demonstrates my problem.