javascript - What would be the best way to track by $index in nested ng-repeat? -



javascript - What would be the best way to track by $index in nested ng-repeat? -

i have next html:

<div class="row" ng-repeat="row in grid track $index"> <div cell class="cell" ng-repeat="cell in row track $index" ng-click="game.additem($index, $index)"> {{cell.value}} </div> </div>

i need track index in first ng-repeat , in second, in order pass them off additem(). best way pass both of them?

i belieive can do:

<div class="row" ng-repeat="row in grid track $index" ng-init="$rowindex = $index"> <div cell class="cell" ng-repeat="cell in row track $index" ng-click="game.additem($rowindex, $index)"> {{cell.value}} </div> </div>

(init might need go on outer div, can't recall sit down here)

although question beg, why can't utilize cell , row, need indexes for.

javascript angularjs angularjs-ng-repeat

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -