I have a fairly simple textboxfiltering ng-repeaton some unordered lis. When I add a value to textbox, elements with values nullare deleted and not returned even when cleared textbox. I have an idea why this happens (the search object now has an empty property that does not match nulls), but I cannot figure out how to solve the problem. I tried the pop()property 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 check out JSfiddle to better illustrate the problem.
source
share