我正在使用angular.bootstrap()初始化我的应用程序。之后,我想为$ rootScope分配一些值。我正在尝试这样做,但对我不起作用:
var app = angular.module('myApp', []);
var modulesToLoad = ['myApp'];
angular.bootstrap(b, modulesToLoad);
app.run(function($rootScope) {
$rootScope.isLoading = false;
}
最佳答案
bootstrap函数返回$injector
,因此您可以执行以下操作:
var app = angular.module('myApp', []);
var modulesToLoad = ['myApp'];
var injector = angular.bootstrap(b, modulesToLoad);
injector.invoke(function($rootScope) {
$rootScope.isLoading = false;
});