I have a list with the items (name: String, age: Int, checked:Boolean). This list is displayed with an ng-repeat. I want to enable the user to search the list using a searchfield, but the search must not affect the checked-values.
- the search should only trigger, if the users enters something in the searchfield
- if the seachfield is filled, the search should filter as usual, but the checked items must not be filtered out.
I tried to create a custom filter. I have problems in understanding the $filter('filter') function with my OR-logic.
Could anyone help me untie the knot in my brain?
app.filter('mySearchFilter', function($filter) {
return function(data, searchText) {
if(!searchText || searchText.length === 0) {
return data;
}
console.log(searchText);
return $filter('filter')(data, searchText);
//how can I provide additional, OR-concatinated, filter-criteria?
}
});
Check out my plunk for the minimal-example-code.