If I have multiple ng-repeat loops nested within each other like in the following example:
<div ng-repeat="outeritem in outerobject">
<div ng-repeat="inneritem in innerobject" ng-click="function(inneritem.key, $index)"></div>
<div>
How can I access the $index
value from the outterobject loop inside the function(inneritem.key, $index)
function that is inside the ng-click
directive of the innerobject loop?
Update:
I ultimately decided to implement this approach, despite there being two other viable solutions mentioned in the comments below.
<div ng-repeat="(indexvalue, outeritem) in outerobject">
<div ng-repeat="inneritem in innerobject" ng-click="function(inneritem.key, indexvalue)"></div>
<div>