Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ngx-pipes filter by multiple conditions

Tags:

angular

pipe

I'm using ngx-pipes plugin(https://github.com/danrevah/ngx-pipes#filterby) in my ANgular project. And I don't find a way to filter by multiple properties.

My data looks like this

[{'name': 'tom', 'age':12, location:'denver'},
{'name': 'jerry', 'age':11, location:'denver'},
{'name': 'scott', 'age':12, location:'denver'}, 
{'name': 'tiger', 'age':13, location:'colarado'},
{'name': 'lion', 'age':11, location:'denver'}]

Now, I want to use filterBy pipe to filter the data whose age is 11, and whose location is 'Denver'.

Please help me with this.

like image 454
Pavan Elthepu Avatar asked Nov 19 '25 12:11

Pavan Elthepu


1 Answers

You can chain pipes.

p>{{ users | filterBy: ['age']: 11 | filterBy: ['location']: 'Denver' }}</p> 

If you have a large array this may cause performance issues. This is the reason why angular 2+ do not have a filter pipe implemented. Keep this in mind. Read this for better understanding.

like image 63
zgue Avatar answered Nov 21 '25 04:11

zgue



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!