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

2
  • Frankly speaking, I don't understand at all what you are trying to achieve. Could you post a plunker/jsFiddle to demonstrate your problem? Commented Jun 26, 2014 at 15:15
  • stackoverflow.com/questions/13216115/… Commented Jun 26, 2014 at 15:16

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.