Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-repeat: how to add multiple filters?

I'd like to use multiple filters on the same item for an ng-repeat. The idea is that for each job below I have different properties like location and salary and I'd like to be able to filter the results with both criteria.

So far, I've tried this:

<div ng-repeat="job in jobs | filter: location | filter: salary">

But it's obviously not working.

Does anyone have a clue how to fix this?

Thanks

like image 720
Spearfisher Avatar asked Jan 19 '26 05:01

Spearfisher


1 Answers

You can create a custom filter.

<div ng-repeat="job in jobs | filter:customFilter">

And in your controller :

 $scope.customFilter = function(item) {
   if('Condition on your item')
     return true;
   return false;

 }
like image 71
R3tep Avatar answered Jan 20 '26 18:01

R3tep