When I minify/obfuscate/uglify my code, my httpInterceptor is not working anymore.
I get the following error :
Error: error:unpr
Unknown Provider
Unknown provider: aProvider <- a
My code with all irrelevant stuff removed:
angular.module("MyApp").factory('sessionChecker', ['$q', '$injector',
function ($q, $injector) {
var sessionRecoverer = {
responseError: function (response) {
// Session has expired
if (response.status === 401) {
var $location = $injector.get('$location');
var $modal = $injector.get('$modal');
$location.path("/login");
} else if (response.status === 500) {
var $location = $injector.get('$location');
//Do stuff..
} else if (response.status === 0) {
var $modal = $injector.get('$modal');
//Do stuff..
}
return $q.reject(response);
}
};
return sessionRecoverer;
}]);
angular.module("MyApp").config(['$httpProvider',
function ($httpProvider) {
$httpProvider.interceptors.push('sessionChecker');
}]);
How would I inject my dependencies correctly, or am I missing something? This is working fine without minifying my code.
Any help would be appreciated.
aProviderdoesn't exist in the source code you have shown, why are you using the$injectorto inject things, that can be injected through the constructor...