Mahesh Gali
Mahesh Gali

Reputation: 49

angular JS exact filter in controller

$scope.gradeC = $filter('filter')($scope.results.subjects, {grade: 'C'})[0];

This will give matched results.

Any idea on how to filter only exact matches?

Upvotes: 0

Views: 2074

Answers (1)

Shripal Soni
Shripal Soni

Reputation: 2448

You can pass a strict comparator flag as an argument to the filter.

$scope.gradeC = $filter('filter')($scope.results.subjects, {grade: 'C'}, true)[0];

Ref: Angular filter doc

Upvotes: 3

Related Questions