angular.js 过滤器的反极性 [英] Reverse polarity of an angular.js filter
本文介绍了angular.js 过滤器的反极性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定一个过滤器方法,它在满足某些条件时返回 true,是否可以在 HTML 中调用它的对立面,例如使用:
Given a filter method that returns true if some condition is met, is it possible to invoke its opposite in HTML, e.g. to use:
"item in items | filter:!AllDay"
代替
"item in items | filter:AllDay"
?或者您是否必须维护两种单独的过滤器方法(一种用于 false,一种用于 true)?
? Or do you have to maintain two separate filter methods (one for false and one for true)?
推荐答案
正如 ENDOH(这个问题在技术上是重复的),您可以通过在前面加上 '!' 来否定过滤器到过滤器字符串,如下所示:
As noted by ENDOH (this SO question is technically a duplicate), you can negate a filter by prepending '!' to the filter string, like this:
filter:'!'+myFilter
注意'!'被引用.documentation 在这方面不是很清楚,有一个例子会有帮助.
Note that the '!' is quoted. The documentation is not terribly clear on this, and an example there would be helpful.
这篇关于angular.js 过滤器的反极性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文