On 4 February 2014 10:33, Johannes Zorn <[email protected]> wrote: > Hi, > > I implemented an httpInterceptor in the config block of an application that > requires access to the $httpProvider to set the default Authorization > header. Now I'd like to move this interceptor to a service. I assume it is > not possible to access the $httpProvider in a service. Is there another way > to set a header for all following HTTP requests? What's the best practise in > that case?
You can set future request defaults via the standard $http service's $http.defaults. I'm adding an Authorization header using that and it seems to work well. See http://docs.angularjs.org/api/ng.$http#description_setting-http-headers for details. - Matt -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/groups/opt_out.
