Reputation: 681
I want to filter through multiple statuses.
I have the following JSON
[{name:'firstPerson',status:1},{name:'secondPerson',status:2},{name:'thirdPerson',status:3}]
And I loop through them
<div class="card" data-ng-repeat="res in result | filter:{ status:0, status:2} as avilableNames" >
<div class="item item-text-wrap">
<div class="row">
<div class="col">
<li>{{res.name}}</li>
</div>
</div>
</div>
</div>
<ul>
<li ng-if="avilableNames.length===0">
There are no available names for that status
</li>
</ul>
I have tried:
| filter:{ status:0, status:2}
| filter:{ status:0} | filter:{ status:2}
| filter:{ status:[0,2]}
| filter:{ status:0} || { status:2}
| filter:{ status:myFilter}
which has the function below in my controller
$scope.myFilter = function (item) { return item = 0 || item = 2 ; };
Upvotes: 0
Views: 742
Reputation: 1125
You can use a filter function like this; notice the .status
:
$scope.myFilter = function(item){
return item.status == 0 || item.status == 2;
};
And in your ng-repeat
use it like this :
<div ng-repeat="res in results | filter:myFilter">{{res.name}}</div>
Upvotes: 3