Answer the question
In order to leave comments, you need to log in
How to inject a factory into a factory?
I'm trying to write a $http interceptor. And in it, when receiving a response, you must call the method of one factory. It is logical to assume that you need to inject this factory. As a result, this code:
/*global angular*/
(function () {
'use strict';
angular
.module('App')
.factory('httpErrorResponceInterceptor', ['$rootScope',
//'authFactory',
'$log',
httpErrorResponceInterceptor]);
httpErrorResponceInterceptor.$inject = ['$rootScope',
//'authFactory',
'$log'];
/*@ngInject*/
function httpErrorResponceInterceptor($rootScope,
//authFactory,
$log) {
var self = {};
self.response = function(response) {
$log.debug('call authFactory.errorResponse');
//authFactory.errorResponse(response);
$log.debug('authFactory.errorResponse called');
return response;
}
return self;
}
})();
Answer the question
In order to leave comments, you need to log in
You either write dependencies in an array:
.factory('httpErrorResponceInterceptor', ['$rootScope',
//'authFactory',
'$log',
httpErrorResponceInterceptor]);
httpErrorResponceInterceptor.$inject = ['$rootScope',
'authFactory',
'$log'];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question