1

I have a filter like :

$scope.Approved = $filter('filter')($scope.Summary.CorpEmployees, { locationId: item.Label, evaluationStatusId: '3' });

For some reason the filter is pulling the records whose evaluationStatusId = 13. Can somebody pls explain why this is happening? How can I make sure that my filter pulls only those records whose evaluationStatusId = 3

7
  • You're using a string, use a number Commented Oct 4, 2016 at 22:50
  • I tried number also but the result is same. Commented Oct 4, 2016 at 22:52
  • You have to use the strict equality parameter called "comparator" in the angularjs docs, otherwise it does a "contains" rather than an "equals" for the filter. docs.angularjs.org/api/ng/filter/filter Commented Oct 4, 2016 at 22:54
  • 1
    It would look like this: $scope.Approved = $filter('filter')($scope.Summary.CorpEmployees, { locationId: item.Label, evaluationStatusId: '3' }, true); Commented Oct 4, 2016 at 22:55
  • @mhodges Thank u that worked. Commented Oct 4, 2016 at 23:06

1 Answer 1

2

As per my comment:

You have to use the strict equality parameter called "comparator" in the angularjs docs, otherwise it does a "contains" rather than an "equals" for the filter.

See angular docs for filter here

It would look like this:

$scope.Approved = $filter('filter')(
    $scope.Summary.CorpEmployees, 
    { locationId: item.Label, evaluationStatusId: '3' }, 
    true // <--- This is the parameter that forces strict equality
);
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.