AngularJS access to $first of ngRepeat parent in a

2019-07-07 07:23发布

问题:

I'm trying to get access to $first of a ngRepeat parent from within a nested ngRepeat. Is there a way to alias or access $first for use within nested ngRepeat? I've tried $parent.$first, but it doesn't appear to work. Outputting to screen by interpolation indicates it has the same value as the $first of the nested child.

$parent.$first // same value as nested child

回答1:

Yeesh, you have to go up two-levels to access the ngRepeat parent directive:

$parent.$parent.$first