在config angularJs中注入$ rootScope [英] inject $rootScope in config angularJs

查看:128
本文介绍了在config angularJs中注入$ rootScope的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题在config angularJS中注入$ rootScope,这是我的代码,但仍然是错误,也许有人帮我如何在config 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;
    }])

这篇关于在config angularJs中注入$ rootScope的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆