AngularJS using $rootScope as a data store

This question is addressed in the AngularJS FAQ quoted here:

Occasionally there are pieces of data that you want to make global to
the whole app. For these, you can inject $rootScope and set values on
it like any other scope. Since the scopes inherit from the root scope,
these values will be available to the expressions attached to
directives like ng-show just like values on your local $scope.

It seems that the team does encourage using $rootScope this way, with this caveat:

Of course, global state sucks and you should use $rootScope sparingly,
like you would (hopefully) use with global variables in any language.
In particular, don’t use it for code, only data. If you’re tempted to
put a function on $rootScope, it’s almost always better to put it in a
service that can be injected where it’s needed, and more easily
tested.

Conversely, don’t create a service whose only purpose in life is to
store and return bits of data.

This does not put too much load on the $digest cycle (which implements basic dirty checking to test for data mutation) and this is not an odd way to do things.

EDIT: For more details on performance, see this answer from Misko (AngularJS dev) here on SO: How does data binding work in AngularJS? Specifically note the section on performance.

Leave a Comment