Filter Object On Exact Match In AngularJS

Posted By Weston Ganger

I wanted to filter my ng-repeat list but I only wanted exact matches not all that contain the value.

All you have to do is add a flag to tell it to get exact matches

<div ng-repeat="post in posts | filter:{'id':  1}:true">

The ‘:true’ portion tells it to get only exact matches which would be ID == 1

If you set it to ‘:false’ which it does by default it would match 1, 11, 21, 31, etc…

Related External Links:

Article Topic:Software Development - Angular

Date:July 13, 2015