Given two scopes - x, y - is there a built in function that returns true if x is an ancestor of y?
(I can obviously traverse from y to the $rootScope
using $parent
and compare $id
along the way)
EDIT:
In the meanwhile I'm using something like this:
function isChildScope(parentScope, childScope) {
while (childScope) {
if (parentScope.$id === childScope.$id) {
return true;
}
childScope = childScope.$parent;
}
return false;
};