I have the following HTML:
<div class="row" ng-repeat="row in grid track by $index">
<div cell class="cell" ng-repeat="cell in row track by $index" ng-click="game.addItem($index, $index)">
{{cell.value}}
</div>
</div>
I need to track by index in the first ng-repeat and in the second, in order to pass them off to addItem(). What would be the best way to pass both of them?
I belieive you can do:
<div class="row"
ng-repeat="row in grid track by $index"
ng-init="$rowIndex = $index">
<div cell class="cell"
ng-repeat="cell in row track by $index"
ng-click="game.addItem($rowIndex, $index)">
{{cell.value}}
</div>
</div>
(Init might need to go on the outer div, can't recall as I sit here)
Although the question would beg, why can't you just use the cell and row, what do you specifically need the indexes for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With