mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-26 03:00:25 +00:00
fix($http): anonnymous response interceptors should be treated as factories
This commit is contained in:
parent
939c8e8fac
commit
b7f4d8c3c3
2 changed files with 12 additions and 6 deletions
|
|
@ -125,7 +125,11 @@ function $HttpProvider() {
|
|||
responseInterceptors = [];
|
||||
|
||||
forEach(providerResponseInterceptors, function(interceptor) {
|
||||
responseInterceptors.push(isString(interceptor) ? $injector.get(interceptor) : interceptor);
|
||||
responseInterceptors.push(
|
||||
isString(interceptor)
|
||||
? $injector.get(interceptor)
|
||||
: $injector.invoke(interceptor)
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -51,11 +51,13 @@ describe('$http', function() {
|
|||
};
|
||||
});
|
||||
// just change the response data and pass the response object along
|
||||
$httpProvider.responseInterceptors.push(function(httpPromise) {
|
||||
return httpPromise.then(function(response) {
|
||||
response.data += '!';
|
||||
return response;
|
||||
});
|
||||
$httpProvider.responseInterceptors.push(function() {
|
||||
return function(httpPromise) {
|
||||
return httpPromise.then(function(response) {
|
||||
response.data += '!';
|
||||
return response;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// return a new resolved promise representing modified response object
|
||||
|
|
|
|||
Loading…
Reference in a new issue