0

How do I pass multiple arguments into a filter?

Trying the following

mylist = $filter('filter')(array, {'field': 'param1'} ||  {'field': 'param2'} ); 

but this only uses the first filter param rather than both.

What is the correct syntax?

user2085143
  • 4,162
  • 7
  • 39
  • 68
  • Duplicate of http://stackoverflow.com/questions/16227325/how-do-i-call-an-angular-js-filter-with-multiple-arguments – Eria Jan 06 '16 at 11:22
  • Are you trying to filter array where `field == param1 || field == param2` ? – PrinceG Jan 06 '16 at 11:32
  • Here is a possible duplicate http://stackoverflow.com/questions/15868248/how-to-filter-multiple-values-or-operation-in-angularjs – PrinceG Jan 06 '16 at 11:35
  • @prince yes I am. Thought it would be possible without writing a custom filter. – user2085143 Jan 06 '16 at 12:00
  • You would likely have to customize this, but you can pass a function $filter('filter')(array, function(v,i) { return v.field == 'param1' || v.field == 'param2'; } ) https://docs.angularjs.org/api/ng/filter/filter – George Houpis Jan 06 '16 at 16:08

0 Answers0