AngularJS Exact Filter Match in Values

In one of my older AngularJS project I was facing a strange issue, there were two select boxes with values populated differently in them. The values in second select drop-down depend upon the first one.

So the required scenario is to show only those values in the second drop down who is under selected value in the first drop down.

take some sample objects for these select drop down as follows:


Now we have ‘id‘ in the first list whose value is given in the second list as ‘parentid‘. now as there is a relation in these lists, we need to show values in the second drop down who’s ‘parentid‘ matched the ‘id‘ in the first list.

Firstly I tried to achieve this using filters as follows:

But this was not working as expected see below image:

Value 1 is also matching 12 😐

I also tried the strict parameter (true) but of no use.

After that, I created this custom filter to strictly filter values


In HTML binding with the filter will look like this

Then it worked as expected! This is just a simple code to help if someone stuck in a similar situation 🙂


Leave a Reply

Notify of