Change this line:
app.config(function($httpProvider, Config) {
to:
app.config(function($httpProvider) {
and this line:
$httpProvider.interceptors.push(function($q) {
to:
$httpProvider.interceptors.push(function($q, Config) {
This works because the function you push to the interceptors is essentially an angular service that can be defined like this:
angular.app('app', [])
.service('HttpInterceptor', function($q, Config) {
return {
request: function() {
// Do whatever
}
};
});
Which can be passed in the config
function like this:
$httpProvider.interceptors.push('HttpInterceptor');
As long as your HttpInterceptor service does not call on $http
or anything that depends on $http
(... like $resource
), you'll be fine. @Ye Liu was right in his comment that services are not allowed to be injected into the config function. However, services can be injected into other services.