Reverse polarity of an angular.js filter

前端 未结 4 791
离开以前
离开以前 2020-12-05 22:56

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:!AllDa         


        
4条回答
  •  有刺的猬
    2020-12-05 23:57

    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
    

    Note that the '!' is quoted. The documentation is not terribly clear on this, and an example there would be helpful.

提交回复
热议问题