AngularJS track by $index quirks

preview_player
Показать описание
I briefly explain why you might want to use "track by $index" in an ng-repeat, then dive into some of the side effects this causes.

Рекомендации по теме
Комментарии
Автор

Thanks man! we are looking for video handle particular row with particular button on same row using ng-repeat. Whenever we try for this, any button click only first row effect through ng-repeat . If any video there please

AnilSahu-zxwk
Автор

It's a feature not a bug. The intention of "track by" is to make sure that the DOM elements don't get recreated, so directives on them shouldn't get reinitialized either. If you change the model binding on the input from ng-model="number.plus_one" to ng-model="number.value", then you see that the binding is still working fine.

You are completely negating the benefit of the "track by", by using this $timeout workaround, because you are making sure that the DOM elements are recreated by doing that - which is exactly what you were trying to avoid with "track by".

Sammi
join shbcf.ru