Distinguish between $index in angularJS -
i have 2 ng-repeats, 1 inside other.
<table ng-repeat="all in values track $index"> <tr ng-repeat = "errors in track $index"> // want use $index of both ng-repeats </tr> </table>
i have use $index of both ng-repeats. how can distinguish 1 $index other?
when using $parent.$index
getting parents index:
<div ng-app="myapp"> <div ng-controller="myctrl"> <div ng-repeat="data in parent track $index"> <div ng-repeat="data1 in data track $index"> {{$parent.$index}}:{{$index}} </div> </div> </div> </div>
where myapp is:
angular .module('myapp',[]) .controller('myctrl',function($scope){ $scope.parent = [ ['a','e','i','o','u'], ['a1','e1','i1','o1','u1'], ['a2','e2','i2','o2','u2'], ]; });
you can have @ more details in this jsbin.
Comments
Post a Comment