Access outer $index when ng-repeat are nested in AngularDart
As @Randal Schwartz pointed out in this post $parent
does the trick.
<div ng-controller='demo-ctrl'> <div ng-repeat="row in ctrl.matrix"> <div ng-repeat="column in row"> <span>outer: {{$parent.$index}} inner: {{$index}}</span> </div> </div></div>
You need ng-init
from Angular.js. Sadly, that hasn't been ported yet, but it would look like this if it worked:
<script> function Ctrl($scope) { $scope.list = [['a', 'b'], ['c', 'd']]; }</script><div ng-controller="Ctrl"> <div ng-repeat="innerList in list" ng-init="outerIndex = $index"> <div ng-repeat="value in innerList" ng-init="innerIndex = $index"> <span class="example-init">list[ {{outerIndex}} ][ {{innerIndex}} ] = {{value}};</span> </div> </div></div>