mardi 11 août 2015

How to access $parent of ng-repeat within ng-include

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.

Aucun commentaire:

Enregistrer un commentaire