1

I have a filter on the JS side of angular.

$filter('filter')($scope.ArrayofUserObjects, {Active: true, ID: passedInValue});

NOTE - my array is is an array of objects

Let's say my array has 50 active users and 10 inactive users.

The passedInValue is an inactive user's ID. This filter at present will return 0 because each parameter of the array in essence is && together.

Question ---

I would like to alter this filter so the objects are || together, which means the resulting filter would return 51

Is this possible?

3
  • Filters are functions so they should be able to return whatever you want but I have trouble understanding what you mean to ask. Commented Mar 19, 2016 at 3:47
  • Do you to add $scope.array and the second object passed as arguments? Commented Mar 19, 2016 at 3:54
  • Possible duplicate of How to filter multiple values (OR operation) in angularJS Commented Mar 19, 2016 at 5:09

1 Answer 1

1

Create your own filter:

$filter('filter')($scope.ArrayofUserObjects, function(value){return value.Active || value.ID == passedInValue});
Sign up to request clarification or add additional context in comments.

1 Comment

I needed to use this in more than one place, so I broke it out into a function by itself. Thanks for the help.

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.