I want to use the filter
in angular and want to filter for multiple values, if it has either one of the values then it should be displayed.
I have for example this structure:
An object movie
which has the property genres
and I want to filter for Action
and Comedy
.
I know I can do filter:({genres: 'Action'} || {genres: 'Comedy'})
, but what to do if I want to filter it dynamically. E.g. filter: variableX
How do I set variableX
in the $scope
, when I have an array of the genres I have to filter?
I could construct it as a string and then do an eval()
but I don't want to use eval()...
My solution
I wrote this for strings AND functionality (I know it's not the question but I searched for it and got here), maybe it can be expanded.
Usage: