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

3
  • 2
    Have you tried returning a filter function like this Commented Aug 25, 2015 at 0:17
  • I have not I will try that Commented Aug 25, 2015 at 0: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. Commented Jan 23, 2017 at 13:19

0

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.