Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

I have an array of products that I'm repeating overusing ng-repeat and I am using

<div ng-repeat="product in products | filter:by_colour">

to filter these products by colour. The filter is working but if the product name/description etc contains the colour then the product remains after the filter is applied.

How do I set the filter to only apply to the colour field of my array rather than every field?

1 Answer

0 votes
by (106k points)

To set the filter to only apply to the colour field of my array rather than every field m you can use an object, and set the color in the color property see the code below:-

Search by color: <input type="text" ng-model="search.color"> <div ng-repeat="product in products | filter:search">

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...