I have a variable called narrow.searchedMenu
that contains 3 arrays of equal length. To display them, I am using ng-repeat
with track by $index
due to some duplicate elements present.
<ul>
<li ng-repeat="item in narrow.searchedMenu.description track by $index">
{{ narrow.searchedMenu.name[$index] }},
{{ narrow.searchedMenu.short_name[$index] }},
{{ narrow.searchedMenu.description[$index] }}</li>
</ul>
My goal is to filter the displayed results based on keywords appearing in the description
. If a description
does not match, I want to exclude the corresponding name
, short_name
, and description
.
In normal circumstances, I would use something like this:
| filter{description:'chicken'}
However, when I try to add it to the ng-repeat
statement along with track by
, it throws an error:
Error: [$parse:syntax] http://errors.angularjs.org/1.5.8/$parse/syntax?p0=%7B&p1=is%20an%20unexpected%20token&p2=16&p3=NaNndex%20%7C%filter%7Bdescription%3A'chicken'%7D&p4=%7Bdescription%3A'chicken'%7D
I've tried different approaches but haven't had any success so far.
It's worth mentioning that the $scope
isn't injected into my controller. When attempting to use a custom filter, I encounter the following error:
"Error: [filter:notarray] errors.angularjs.org/1.5.8/filter/notarray?p0=0";
Lastly, I've been advised against using includes
due to lack of broad support. There was mention of using a polyfill
as an alternative solution, though I'm unsure if it applies in this case.