Reputation: 2483
I'm using ng-repeat to display an array, and using the filter. My array has many keys, and I was able to apply filter to one specific key:
ng-repeat="project in projects = (list | filter: { name: filter }) | orderBy: 'name'"
But when I describe a filter, it should display array entries where the string from filter is found either in name or description.
Any suggestions?
http://plnkr.co/edit/scuPYt?p=preview
Upvotes: 1
Views: 540
Reputation: 582
You'll need to create a search filter in your $scope for that controller:
$scope.searchFilter = function (project) {
var keyword = new RegExp($scope.filter, 'i');
return !$scope.filter || keyword.test(project.name) || keyword.test(project.description);
};
And then change the ng-repeat to:
ng-repeat="project in projects | filter: searchFilter) | orderBy: 'name'"
You may need to add list back in - not come across that before.
Upvotes: 1