I am building a table and I have two ng-repeat
for my table.
My question is if it\'s possible the child of the ng-repeat
can get the parent
This is exactly where ng-init comes into picture, to alias special properties of ng-repeat, ex: ng-init="companyIdx=$index"
. So each child scope created by company ng-repeat
will have this companyIdx
property.
company # = {{companyIdx}} and product {{$index}}
Using a $parent
is fine but it you have any other directive that creates a child scope in between them, eg:- ng-if
, another ng-repeat
etc.. you will have to go crazy doing $parent.$parent....
. Aliasing with ng-init
makes it clean and more readable and maintainable as well.