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

<code class="language-markup">
<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:

- [Stack Overflow - Angular filter exactly on object key](

Article Topic:Software Development - Javascript

Date:July 13, 2015