I have a list filtered like this:
ng-repeat=\"item in items | filter:query | limitTo:10\"
and a search input
ng-model=\"search.
Two hints for the answer from gion_13.
If the query is a empty string (after filtering and then deleting the search term), then the input "apple" is modified like this: apple
The solution for this is to change either the regex or a early return:
.filter('searchfilter', function() {
return function (input, query) {
if (query === '') {
return input;
}
return input.replace(RegExp('('+ query + ')', 'g'), '$1');
}
});
If you don't want a case sensitive filter than change the RegExp:
RegExp('('+ query + ')', 'gi'), '$1');