javascript - Why track by $index is necessary for ng-click to trigger inside nested ng-repeat -
i using ng-click
inside nested ng-repeat
found inner ng-click(3rd level) not getting triggered. when used track $index
inner ng-repeat, ng-click got triggered. not able understand behavior of nested ng-repeat.
please find below code snippet
<ul class="a"> <li class="b" ng-repeat="items in objects track $index" ng-click="callsomething()"> <a>{{items.name}}</a> <ul class="c"> <li class="d" ng-repeat="items1 in objects1 track $index" ng-click="callsomething()"> <a>{{items1.name}}</a> <ul class="e"> <li class="f" ng-repeat="items2 in objects3 track $index" ng-click="callsomething()"> <a>{{items3.name}}</a> </li> </ul> </li> </ul> </li> </ul>
its related ng-repeat behavior. each element tracked uniquely , mapped scope. think thread answers questions:
Comments
Post a Comment