You can use filter with! predicate that negates the search string:
div ng-repeat="item in items | filter:'!Red' | filter: '!Green'">{{item['flowers']}}</div>
So filter:'!Red' deletes everything that has the string βRedβ in it. These results are passed to filter: '!Green' , which deletes any results that contain the string βGreenβ in them.
Here's the relevant docs: http://docs.angularjs.org/api/ng.filter:filter
Performance update
I was interested to know about the cost of filtering, so I did it jsperf: http://jsperf.com/angular-ng-repeat-test1/2
I created 1000 lines ( items ) and then performed 4 tests with the following results on my system:
1) Display all 1000 using DI 281,599 ops / sec
{{items}}
2) Display all 1000 with ng-repeat (no filter): 209 946 options per second 16% slower
<div ng-repeat="item in items"> {{item}}</div>
3) ng-repeat with one filter 165 280 ops / sec 34% slower
<div ng-repeat="item in items | filter:filterString1"> {{item}}</div>
4) ng-repeat with two filters 165 553, ops / sec 38% slower
<div ng-repeat="item in items | filter:filterString1 | filter:filterString2"> {{item}}</div>
This, of course, is not a scientific test - I did not make any controls, and it is possible that things like caching influenced the results. But I think relative performance is interesting.
source share