Every AngularJS application has a single root scope. All other scopes are descendant scopes of the root scope. Scopes provide separation between the model and the view, via a mechanism for watching the model for changes. They also provide an event emission/broadcast and subscription facility.
Every part of an AngularJS application has a scope. At the ng-app
level, this scope is called the $rootScope
. When Angular starts to run and generate the view, it creates a binding from the root ng-app
element to the $rootScope
. This $rootScope
is the eventual parent of all $scope
objects. So we can say that the $rootScope
object is the closest object we have to the global context in an Angular app.
$rootScope
is deprecated. Using it will make migration to Angular 2+ more difficult.