Angularjs filter negated

后端 未结 6 703
迷失自我
迷失自我 2020-11-30 10:01

I have a set of items that I want to filter in ng-repeat using an ng-model as the string to filter the set, so far I haven\'t found a way to make it work when the expression

6条回答
  •  既然无缘
    2020-11-30 10:33

    To completely negate the $filter filter, i add this filter:

    .filter('$nfilter', ['$filter', function($filter) {
        return function() {
            var itemsToExclude = $filter('filter').apply(null, arguments);
            return arguments[0].filter(x => !itemsToExclude.includes(x));
        }
    }])
    

    in template, we can write:

    
        

提交回复
热议问题