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.
(我想使用角度filter
,并希望过滤多个值,如果它具有值之一,则应该显示它。)
I have for example this structure:
(我有这样的结构:)
An object movie
which has the property genres
and I want to filter for Action
and Comedy
.
(具有属性genres
的对象movie
,我想为Action
和Comedy
过滤。)
I know I can do filter:({genres: 'Action'} || {genres: 'Comedy'})
, but what to do if I want to filter it dynamically.
(我知道我可以filter:({genres: 'Action'} || {genres: 'Comedy'})
,但是如果我想动态过滤它该怎么办。)
Eg filter: variableX
(例如, filter: variableX
)
How do I set variableX
in the $scope
, when I have an array of the genres I have to filter?
(当我有必须过滤的流派数组时,如何在$scope
设置variableX
?)
I could construct it as a string and then do an eval()
but I don't want to use eval()...
(我可以将其构造为字符串,然后执行eval()
但我不想使用eval()。)
ask by JustGoscha translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…