AngularJS在嵌套的ngRepeat中访问ngRepeat父对象的$ first [英] AngularJS access to $first of ngRepeat parent in a nested ngRepeat

查看:99
本文介绍了AngularJS在嵌套的ngRepeat中访问ngRepeat父对象的$ first的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从嵌套的ngRepeat中访问ngRepeat父对象的$ first.有没有一种方法可以别名化或访问$ first以便在嵌套的ngRepeat中使用?我已经尝试了$ parent.$ first,但是它似乎没有用.通过插值输出到屏幕表示它与嵌套子项的$ first具有相同的值.

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

推荐答案

是的,您必须上两个级别才能访问ngRepeat父指令:

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

$parent.$parent.$first

这篇关于AngularJS在嵌套的ngRepeat中访问ngRepeat父对象的$ first的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆