Reputation: 3740
I have a ng-repeat inside a ng-repeat with a ng-include inside of the inner ng-repeat. Inside that ng-include, I want to access the outer ng-repeat with $parent. Here is my sample code:
index.html
<div ng-repeat="population in populations">
<div ng-repeat="person in population">
<div ng-include="person.url"></div>
</div>
</div>
one_person.html ("person.url" resolves to this)
<div> Your population id is {{ $parent.$index }}</div>
I am not able to access $parent.$index
from that ng-include
.
Upvotes: 0
Views: 459
Reputation: 25352
ngRepeat create scope so as ngInclude
Try like this
<div ng-repeat="population in populations">
<div ng-repeat="person in population">
<div ng-include="person.url" onload="parent=$parent.$parent"></div>
</div>
</div>
person.url
<div> Your population id is {{ parent.$index }}</div>
Upvotes: 1