r mk r
r mk r

Reputation: 299

Filter producing wrong results Angularjs

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

Upvotes: 1

Views: 394

Answers (1)

mhodges
mhodges

Reputation: 11116

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
);

Upvotes: 2

Related Questions