Is it possible to filterBy multiple values in emberjs?
You can't pass multiple properties into the same filterBy
, but you can filterBy
on the same array 2 times, i.e. chain your filterBy
calls if that makes sense.
See the following answer I recently gave (here) for a working demo of what I am talking about
So, in short, if you have an array arr and you want to filter it by country
and name
properties for example, you would do:
arr.filterBy('country', countryName).filterBy('name', 'Josh')
You can also just use the filter
(as opposed to filterBy
) method and filter things any way you would like.
I blogged a solution at http://www.emberdaily.com/2019/02/25/filter-by-multiple-values/
Essentially,
this.get('myProjects').filter(project => project.get('status') === 'done' || project.get('status') === 'active');