Filter for array of arrays in AngularJS

posted in: Angular, Javascript | 0

Problem: We want to build a tag filtering system and be able to filter ou results by objects containing one of the specified tag or all the tags.


Let’s say you have some objects, for example Cocktails which looks like this:


You would like to implement a search by tags for example searching ecocktails containing those ingredients:

toSearch = ["orange", "banana"];

You can write a filter like this:

This will give you the list of items containing at least one ingredient.


You can call it with something like this:


To have a strict result:

This will give you the list of cocktails containing every of the specified ingredients.


Have a look at some usage here:


Leave a Reply