给定两个示波器 - x,y - 是否有内置函数,如果x是y的祖先,则返回true?是否有内置的方法来知道范围是否是另一个范围的孩子?
(我可以明显地从y中穿越到$rootScope
使用$parent
一路上比较$id
)
编辑:
在这期间我使用的是这样的:
function isChildScope(parentScope, childScope) {
while (childScope) {
if (parentScope.$id === childScope.$id) {
return true;
}
childScope = childScope.$parent;
}
return false;
};
可能,这可能回答这个问题:http://stackoverflow.com/a/13428220/1059101 – Jai 2014-09-04 12:19:51
@Jai - 这个答案没有任何与我的问题......我并不想访问子范围,只要找出一个范围是否是另一个范围的祖先。 – seldary 2014-09-04 12:23:53
所以你想在代码或角铬扩展名为batarang肯定会帮助你。 – Jai 2014-09-04 12:25:39