Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

inject $rootScope in config angularJs

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. .

thanks.

(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>';
  }
})();
like image 758
johnHarry Avatar asked Sep 17 '26 19:09

johnHarry


1 Answers

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;
    }])
like image 169
Satpal Avatar answered Sep 19 '26 13:09

Satpal