Friday, December 20, 2013

Angular.js: Combining $index and orderBy filter

When creating an application with Angular.js, I was using the $index variable inside an ng-repeat to track the index of the current item. The problem was that the moment I start combining this with an orderBy filter, the $index value was no longer correct.

I worked around the issue by passing the item itself around instead of the index.  In my function I used the indexOf method of an array.

Anyone with a better solution?

4 comments:

Anonymous said...

This saved my life thanks much!!!

Anonymous said...

This saved my life thanks much!

Anonymous said...

This saved my life thanks much!

Melvin Schneiders said...

This didn't save my life but a lot of time :) Thank you very much!