Luke101
Luke101

Reputation: 65238

How to use filter with "and" or "or"

I need to filter by multiple properties using an and. How would I do something like this in angular:

ng-options="item.licenseName for item in licenses | filter: {centerId: selectedLocation.centerId and selectedLocation.state is not null}"></select>

notice the and selectedLocation.state is not null at the end. How can I add functionaliy like this to angular.

Upvotes: 0

Views: 53

Answers (1)

AlexHv
AlexHv

Reputation: 1734

The "and" is made by putting several filters or defining a custom one. (Note that in the first case, the second filter will be applied to the result of the filtering of the inputs by the first filter).

You could do this :

ng-options="item.licenseName for item in licenses | filter: {centerId: selectedLocation.centerId } | filter: {selectedLocation.state !== null}"></select>

Upvotes: 1

Related Questions