I have a shared function which returns of the scope of the topmost element (document) in my AngularJS application.
function topScope() {
return angular.elemen
$rootScope
is a parent scope of all scopes in a given AngularJS application. Since it is possible to bootstrap multiple AngularJS applications on one page (only manually, this can't be done using ng-app
) it is also possible to have multiple $rootScope
instances in one HTML documents.
Each $rootScope
is "attached" to either the element where ngApp was declared or the element passed into angular.bootstrap as described here.
In short, the $rootScope
is a root of all scopes for one AngularJS application but there is no "super-root" scope that would serve as a parent scope of all other scopes for a given HTML document.
In your case using the $rootScope
might be OK if you've got only one AngularJS application in the whole HTML document.