Reputation: 261
I have a problem when the attribute of the object does not exist and I can not filter using "!null"
, I wonder if filter can validate this or i need to create a new filter for this.
Html ng-repeat
<li ng-repeat="detail in details | filter:{shortDescription: '!null'}">
<p>{{detail.name}}</p>
</li>
JavaScript Array
$scope.details = [{
name: 'Bill',
shortDescription: null
},{
name: 'Bill2',
}, {
name: 'Sally',
shortDescription: 'A girl'
}];
Result
Bill2 have no exist shortDescription
but not filter.
expected Result:
JSFiddle http://jsfiddle.net/4wxs67yv/28/
AngularJS v.1.3.15
How i can do this?
Upvotes: 1
Views: 115
Reputation: 100205
You could try using double not operator,as
<li ng-repeat="detail in details | filter:{shortDescription: '!!'}">
<p>{{detail.name}}</p>
Upvotes: 1