0

I have a filter in a view which works fine:

<ng-repeat="order in orders | filter:approved=true"">

However I would like this filter in the root controller as non approved objects never to be parsed.
What do I need to get that result?

controller('test', function($scope, $filter) { 
  $filter   ?????

1 Answer 1

1

Usage is:

$filter(filterName)(array, expression, comparator)

So in your case its:

$scope.orders = $filter('filter')($scope.orders, { approved: true})

https://docs.angularjs.org/api/ng/filter/filter

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.