我正在使用 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;
});
关于javascript - 如何在 angular.bootstrap() 之后设置 $rootScope 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13198443/