Tuesday, 20 August 2013

Conditional classes applied in ng-repeat using $index inconsistent when filtering

Conditional classes applied in ng-repeat using $index inconsistent when
filtering

I have a ng-repeat which is filtered with an input box. In this list,
there are .active and .disabled items. Everything renders correctly, but
when I filter it with a query, the active and disabled classes are messed
up because the index of the display changed.
Here is a jsFiddle showing the problem. You see that the second row is
highlighted (class active added). Now try to type "iphone" in the input
box. The second line will be highlighted, even if it's not active.
How can I get around this and have reliable data in my ng-repeat?

No comments:

Post a Comment