AngularJS models are held in the
$scope object. In AngularJS,
$scope is used to gain access to the model related to a particular controller.
$rootScope is a parent scope that can be used to save and access model properties that span multiple controllers. The use of
$rootScope is highly discouraged in most designs, however. There is only one
$rootScope in an application.
$scope is a child scope of
A properly designed AngularJS application will have little or no use for
$rootScope to store model properties. In this chapter we will focus only on
$scope, used to store the model retrieved from REST services.
The following excerpt shows how AngularJS services access the REST services used for this chapter. The REST services return the same JSON that was previously hardcoded in the controllers:
/* chapter7/services.js excerpt */