June 2014
Intermediate to advanced
696 pages
38h 52m
English
When an application is bootstrapped, a root scope is created. The root scope stores data at the application level, and you can access it by using the $rootScope service. The root scope data should be initialized in the run() block of the module, but you can also access it in components of the module. To illustrate this, the following code defines a value at the root scope level and then accesses it in a controller:
angular.module('myApp', []).run(function($rootScope) { $rootScope.rootValue = 5;}).controller('myController', function($scope, $rootScope) { $scope.value = 10; $scope.difference = function() { return $rootScope.rootValue - $scope.value; ...
Read now
Unlock full access