Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 163e05e

Browse files
committed
feat($http): allow interceptors to be services
1 parent 2986a09 commit 163e05e

File tree

2 files changed

+530
-491
lines changed

2 files changed

+530
-491
lines changed

src/service/http.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,18 @@ function $HttpProvider() {
8383

8484
var responseInterceptors = this.responseInterceptors = [];
8585

86-
this.$get = ['$httpBackend', '$browser', '$exceptionHandler', '$cacheFactory', '$rootScope', '$q',
87-
function($httpBackend, $browser, $exceptionHandler, $cacheFactory, $rootScope, $q) {
86+
this.$get = ['$httpBackend', '$browser', '$exceptionHandler', '$cacheFactory', '$rootScope', '$q', '$injector',
87+
function($httpBackend, $browser, $exceptionHandler, $cacheFactory, $rootScope, $q, $injector) {
8888

8989
var defaultCache = $cacheFactory('$http');
9090

91+
forEach(responseInterceptors, function(interceptor, index) {
92+
if (isString(interceptor)) {
93+
responseInterceptors[index] = $injector.get(interceptor);
94+
}
95+
});
96+
97+
9198
/**
9299
* @ngdoc function
93100
* @name angular.module.ng.$http

0 commit comments

Comments
 (0)