Archipel Archipel - 1 year ago 52
AngularJS Question

$filter to find single item with ID (AngularJS)

I'm trying to find an item in an array with an ID.
I get that ID from my url and I tried to use $filter to extract it from my array.

Here's what my code looks like :


so bassically:


It works but the problem is that it also returns other item with the same number in the ID

Example: If my url is #/3, it will return the object with id 23,13,3,33 etc...

How can I filter my array to only find the exact one ?

Answer Source

Just pass the true option to match exactly as the third parameter to the filter: