Reverse polarity of an angular.js filter

前端 未结 4 815
离开以前
离开以前 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:51

    Another option is to create a new negation filter and pipe it:

      .filter('not', function() {
        return function(input) {
          return !input;
        }
      })
    
    "item in items | filter:AllDay | filter:not"
    

提交回复
热议问题