1

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?

SOLVED

http://plnkr.co/edit/scuPYt?p=preview

Julius
  • 2,473
  • 3
  • 20
  • 26
  • Frankly speaking, I don't understand at all what you are trying to achieve. Could you post a plunker/jsFiddle to demonstrate your problem? – Abhishek Jain Jun 26 '14 at 15:15
  • http://stackoverflow.com/questions/13216115/filtering-by-multiple-specific-model-properties-in-angularjs – Trevor Jun 26 '14 at 15:16

1 Answers1

1

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.

Chris Southam
  • 582
  • 2
  • 5
  • 12