如何在提供程序的配置中处理$ rootScope

时间:2015-03-30 11:45:24

标签: javascript angularjs

我想在provider方法中处理$ rootScope。我不知道如何注射它

 that.app.config ['$authProvider', ($authProvider) ->

    $authProvider.configure
      apiUrl: '/api/v1'
      handleTokenValidationResponse: (response) ->
        // How to handle $rootScope here?
        return response
  ]

1 个答案:

答案 0 :(得分:2)

在提供程序功能中,您无法注入任何服务或工厂。这只能在" $ get"方法

  this.$get = function($injector) {
    return function(exception,cause){
      var rScope = $injector.get('$rootScope');
      rScope.$broadcast('exception',exception, cause);  
    }
  };