Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
408 views
in Technique[技术] by (71.8m points)

javascript - 如何在angularJS中过滤多个值(或操作)(How to filter multiple values (OR operation) in angularJS)

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 ,我想为ActionComedy过滤。)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...