dzm
dzm

Reputation: 23574

Angularjs apply additional selections to filter

I have a repeater and am using the filter to filter a query, such as

ng-repeat="item in items | filter:query"

I've added a select option and want to add that as an additional filter.

Any suggestions as to how to add this in conjunction with the current filter?

Thank you!

Upvotes: 0

Views: 48

Answers (1)

holographic-principle
holographic-principle

Reputation: 19738

Try

ng-repeat="item in items | filter:myFilterFunc"

where

$scope.myFilterFunc = function (item) {
  //return true or false depending on multiple conditions
};

You have access to item as well as anything on the $scope within that function. With some if statements, you should be able to achieve the desired behavior.

Upvotes: 1

Related Questions