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?

ZombieCode
  • 1,646
  • 2
  • 24
  • 46
  • Filters are functions so they should be able to return whatever you want but I have trouble understanding what you mean to ask. – Casey Mar 19 '16 at 03:47
  • Do you to add $scope.array and the second object passed as arguments? – Gary Mar 19 '16 at 03:54
  • Possible duplicate of [How to filter multiple values (OR operation) in angularJS](http://stackoverflow.com/questions/15868248/how-to-filter-multiple-values-or-operation-in-angularjs) – iambriansreed Mar 19 '16 at 05:09

1 Answers1

1

Create your own filter:

$filter('filter')($scope.ArrayofUserObjects, function(value){return value.Active || value.ID == passedInValue});
Frane Poljak
  • 2,315
  • 23
  • 25
  • I needed to use this in more than one place, so I broke it out into a function by itself. Thanks for the help. – ZombieCode Mar 20 '16 at 01:04