在配置 angularJs 中注入 $rootScope [英] inject $rootScope in config angularJs
本文介绍了在配置 angularJs 中注入 $rootScope的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在配置 angularJS 中注入 $rootScope 时遇到问题,这是我的代码,但仍然出错,也许有人帮助我如何在配置 angularJS 中注入 $rootScope..
I have problem to inject $rootScope in config angularJS, this is my code, but still error, maybe anyone help me how to inject $rootScope in config angularJS. .
谢谢.
(function() {
'use strict';
angular
.module('uliappApp')
.directive('angular-loading-bar', ['cfpLoadingBarProvider'])
.config(cfpLoadingBarProvider);
cfpLoadingBarProvider.$inject = ['cfpLoadingBarProvider', '$rootScope'];
function cfpLoadingBarProvider(cfpLoadingBarProvider, $rootScope) {
cfpLoadingBarProvider.includeBackdrop = true;
console.log(rootScope.concessionLoadingScreen);
cfpLoadingBarProvider.spinnerTemplate = '<div class="loading-bar-container">'
+ '<div id="loading-bar-spinner"><div class="spinner-icon"></div></div></div>';
}
})();
推荐答案
配置阶段不需要rootScope
,使用.run()
即可实现代码>.
You don't need rootScope
in configuration phase, it can be simply achieved by using .run()
.
angular
.module('uliappApp')
.run(['$rootScope', function($rootScope){
$rootScope.concessionLoadingScreen = true;
}])
这篇关于在配置 angularJs 中注入 $rootScope的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文