#106 Filter by Multiple Values

Emad Ibrahim
Frontend Weekly
Published in
1 min readFeb 25, 2019

--

There is no way to pass multiple values to filterBy if you want to perform an or. For example, in Hyperlogs, we wanted to display projects that are both active and done and if we try:

return this.get('myProjects').filterBy('status', 'done').filterBy('status', 'active');

we get an empty array because we are filtering by status done AND active which is always going to be zero.

The best way to do this is to use filter instead:

this.get('myProjects').filter(project => project.get('status') === 'done' || project.get('status') === 'active');

Originally published at Ember Daily Tips.

--

--

Emad Ibrahim
Frontend Weekly

Husband, Father of Twins, Published Author, Entrepreneur, Passionate Technologist, Programmer and Productivity Nut. more at https://about.me/eibrahim