1

I have an array of objects named result.data.EAPP_USERS

0:Object

SECURITYCLASS:90

USERID:"ASISH90"

1:Object

SECURITYCLASS:90

USERID:"VANDERSONIR"

2:Object

SECURITYCLASS:90

USERID:"BISWA90"

3:Object

SECURITYCLASS:93

USERID:"TABITHA93"


4:Object

SECURITYCLASS:93

USERID:"ASISH93"

5:Object

SECURITYCLASS:95

USERID:"TAB95"


6:Object

SECURITYCLASS:95

USERID:"ASISH95"

I want to filter data with SECURITYCLASS value 90 and 93. I have tries this code

$scope.OpportunityOwners = $filter('filter')(result.data.EAPP_USERS, { SECURITYCLASS: "90"} || {SECURITYCLASS: "93"});

but the result contains object with SECURITYCLASS value 90 only. i.e

0: Object
SECURITYCLASS: 90
USERID: "ASISH90" 

1: Object
SECURITYCLASS: 90
USERID: "VANDERSONIR"

2: Object
SECURITYCLASS: 90
USERID: "BISWA90"

I know its possible to filter by SECURITYCLASS: "90" and SECURITYCLASS: "93" ; merge them to get the final result.

but Is it possible by using $filter only once?

Is it possible to filter with multiple constraints ?

2

1 Answer 1

3

You should create a custom filter. By evaluating multiple conditions in one filter it will gain 'performance'.

$scope.filterData = function (item) {
    return (item.SECURITYCLASS === 90 || item.SECURITYCLASS === 93);
}

On your view :

<div ng-repeat="item in data | filter:filterData">
    {{::item}}
</div>

See Plunkr

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.