0

I am trying to use a ng-repeat filter, however i can't seem to get it working.

html:

<li dnd-draggable="item" ng-repeat="item in items| filter: integrateFilter">
        </li>

Filter:

  $scope.integrateFilter = function (item) {
            return !$scope.integratesInput ?
                item : (item.type == $scope.itemTypes[0].type);
        };

The structure of the data:

$scope.itemTypes is an array of types that i want to filter with:

products: Array[2]
   0: Object
     type: "food"
   1: Object
     type: "beverage"

The "items" in the list is an array of objects like:

0: Object
  name: "steak"
    type: "food"

So basically i want to filter items with an Array ($scope.itemTypes). The filter i'm using right now only returns one result (0) the beginning of the array. is there a way to use a filter like this? or will i need to loop through the $scope.itemTypes?

Thanks

user2816352
  • 335
  • 1
  • 5
  • 16
  • 2
    Have you tried returning a filter function like [this](http://stackoverflow.com/questions/16474091/angular-custom-filter-function) – logee Aug 25 '15 at 00:17
  • I have not I will try that – user2816352 Aug 25 '15 at 00:19
  • if you want to filter array with array you should do it in the factory rather than scope, although scope is dynamic as in the 2 way data bindings, they are still subject to DOM limitations. – syarul Jan 23 '17 at 13:19

0 Answers0