ngx-pipes按多种条件过滤

时间:2017-10-13 05:25:43

标签: angular pipe

我在我的ANgular项目中使用ngx-pipes插件(https://github.com/danrevah/ngx-pipes#filterby)。而且我找不到按多个属性过滤的方法。

我的数据看起来像这样

[{'name': 'tom', 'age':12, location:'denver'},
{'name': 'jerry', 'age':11, location:'denver'},
{'name': 'scott', 'age':12, location:'denver'}, 
{'name': 'tiger', 'age':13, location:'colarado'},
{'name': 'lion', 'age':11, location:'denver'}]

现在,我想使用filterBy管道来过滤年龄为11岁,位置为“丹佛”的数据。

请帮助我。

1 个答案:

答案 0 :(得分:1)

你可以chain管道。

p>{{ users | filterBy: ['age']: 11 | filterBy: ['location']: 'Denver' }}</p> 

如果您有大型阵列,则可能会导致性能问题。这就是为什么角度2+没有实现过滤管道的原因。记住这一点。阅读this以便更好地理解。

相关问题