Karol Karwacki
Karol Karwacki

Reputation: 51

how to handle $rootScope in config of provider

I would like to handle $rootScope in provider method. I don't know how to inject it

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

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

Upvotes: 1

Views: 184

Answers (1)

Simon Staton
Simon Staton

Reputation: 4505

In the provider function, you cannot inject any service or factory. This can only be done at the "$get" method.

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

Upvotes: 1

Related Questions