I have a pretty simple textbox
filtering an ng-repeat
on some unordered li
s. When I add a value to the textbox
the items with the null
values are removed and do not return even when the textbox
is cleared. I have an idea of why this is happening (the search object now has an empty property which doesn't match the nulls
), but I cannot figure out how to solve the problem. I've tried to pop()
the property off of the search object with no luck.
HTML:
<div ng-controller="ListCtrl">
<input type="text" ng-model="search.age" placeholder="Age"></input>
<ul>
<li ng-repeat="item in items | filter:search">
{{item.name}} - {{item.age}}
</li>
</ul>
</div>
JS:
function ListCtrl($scope) {
$scope.items = [
{'name':'Carl', 'age':69},
{'name':'Neil', 'age':54},
{'name':'Richard'},
{'name':'Chris', 'age':58}
];
}
Please checkout the JSfiddle to better illustrate the issue.