r mk r r mk r - 15 days ago 6x
AngularJS Question

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


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')(
    { locationId: item.Label, evaluationStatusId: '3' }, 
    true // <--- This is the parameter that forces strict equality