I. The difference between $scope and $rootscope
A sentence summary:
$rootScope the scope for the global takes effect
$scope only valid for the current controller scope
Second, the Angularjs module of the Run method
The Run method initializes the global data and only works on the global scope, such as $rootscope
var m1 = Angular.module (' myApp ', []); M1.run ([function ($rootScope) { = ' Hello '; }]); </script>
Third, the code compression problem in Dependency injection
Define a controller, usually by the following code, but in the process of code compression, the parameters in the function may change, $scope may become $sc, or other (here the change is not controllable), once changed, the following bound value will be wrong.
var app = Angular.module ("myApp", []); App.controller (function ($scope) { = ' Zhang San ';});
To solve this problem, add [] outside the function and pass in the string as shown in the following code, because the string does not change during compression .
var app = Angular.module ("myApp", []); App.controller (function ($scope) { = ') Zhang San ';}]);
Angular.js learns the Run method of the two---$scope and $rootscope,angular modules, and the code compression in the dependency injection