You can filter null elements without creating a custom filter.
Using the code in your plunk, this will return null elements:
<ul ng-repeat="p in foo | filter:{state:'!'}" > <li>{{p.name}}</li> </ul>
And vice versa, this will return all nonzero elements:
<ul ng-repeat="p in foo | filter:{state:'!!'}" > <li>{{p.name}}</li> </ul>
The double operator does not convert any value to boolean: the first operator ! converts the true value to logical false , the second inverts the logical value back to true . In my tests, the filter actually only works with state:'' , but I would use it !! just to be safe ...
source share