Примечание: пожалуйста, см. EDIT 2 более короткий пример проблемы
Это мой сокращенный код AuthService:
var Services;
!function(a) {
var b = function() {
function a(a, b, c) {
var d = this;
d.$q = a, d.$http = b, d.$rootScope = c;
}
return a.prototype.login = function(a) {
//....
}, a.AuthServiceFactory = function(b, c, d) {
return new a(b, c, d);
}, a;
}();
a.AuthService = b, b.$inject = [ "$q", "$http", "$rootScope" ], angular.module("eucngts").factory("AuthService", b.AuthServiceFactory);
}(Services || (Services = {}));
И это мой мини-код контроллера, где я получаю ошибку:
var Controllers;
!function(a) {
var b = function() {
function a(a, b, c, d, e, f) {
//...
}
//...
}();
a.HeaderController = b, b.$inject = [ "$scope", "$location", "AuthService", "$rootScope", "$modal", "$timeout" ],
angular.module("eucngts").controller("HeaderController", b);
}(Controllers || (Controllers = {}));
Сообщение об ошибке:
Unknown provider: bProvider <- b <- AuthService
В противном случае, когда я комментирую строки, которые используют эту услугу, мои другие контроллеры и службы работают нормально.
Заказы строк в исходном файле кажутся прекрасными
Мой конкатенированный и ни один мини файл js не работает отлично.
Что я могу быть причиной, чтобы получить эту ошибку.
РЕДАКТИРОВАТЬ
Когда я не добавляю ни один угледефицированный код, а не ушифрованный, он отлично работает
var Services;
(function (Services) {
var AuthService = (function () {
function AuthService($q, $http, $rootScope) {
var self = this;
self.$q = $q;
self.$http = $http;
self.$rootScope = $rootScope;
}
//...
AuthService.AuthServiceFactory = function ($q, $http, $rootScope) {
return new AuthService($q, $http, $rootScope);
};
return AuthService;
})();
Services.AuthService = AuthService;
AuthService.$inject = ['$q', '$http', '$rootScope'];
angular.module('eucngts').factory('AuthService', AuthService.AuthServiceFactory);
})(Services || (Services = {}));
РЕДАКТИРОВАТЬ 2: Это полный код другой службы, который я не мог определить, что более короткая и удобная проверка:
var Services;
!function(a) {
var xxx = function() {
function a(a, zzz) {
var c = this;
this.request = function(a) {
a.headers = a.headers || {};
var zzz = JSON.parse(localStorage.getItem("authorizationData"));
return zzz && (a.headers.Authorization = "Bearer " + zzz.token), a;
}, this.responseError = function(a) {
var zzz = c;
return 401 === a.status && (localStorage.removeItem("authorizationData"), zzz.$location.path("/login")),
zzz.$q.reject(a);
};
var d = this;
d.$location = a, d.$q = zzz;
}
return a.AuthInterceptorServiceFactory = function(kkk, c) {
return new a(kkk, c);
}, a;
}();
a.AuthInterceptorService = xxx, xxx.$inject = [ "$location", "$q" ], angular.module("eucngts").factory("AuthInterceptorService", xxx.AuthInterceptorServiceFactory);
}(Services || (Services = {}));
неэквидированный код:
var Services;
(function (Services) {
var AuthInterceptorService = (function () {
function AuthInterceptorService($location, $q) {
var _this = this;
this.request = function (config) {
var self = _this;
config.headers = config.headers || {};
var authData = JSON.parse(localStorage.getItem('authorizationData'));
if (authData) {
config.headers.Authorization = 'Bearer ' + authData.token;
}
return config;
};
this.responseError = function (rejection) {
var self = _this;
if (rejection.status === 401) {
localStorage.removeItem('authorizationData');
self.$location.path('/login');
}
return self.$q.reject(rejection);
};
var self = this;
self.$location = $location;
self.$q = $q;
}
AuthInterceptorService.AuthInterceptorServiceFactory = function ($location, $q) {
return new AuthInterceptorService($location, $q);
};
return AuthInterceptorService;
})();
Services.AuthInterceptorService = AuthInterceptorService;
AuthInterceptorService.$inject = ['$location', '$q'];
angular.module('eucngts').factory('AuthInterceptorService', AuthInterceptorService.AuthInterceptorServiceFactory);
})(Services || (Services = {}));
в котором говорится:
Unknown provider: kkkProvider <- kkk <- AuthInterceptorService <- $http <- $templateRequest <- $compile
Вот мой ответ на мой вопрос с приветственной помощью @YOU
Мой код типа AuthInterceptorService
для класса AuthInterceptorService
module Services {
export class AuthInterceptorService {
$location: ng.ILocationService;
$q: ng.IQService;
constructor($location, $q) {
var self = this;
self.$location = $location;
self.$q = $q;
}
//...
static AuthInterceptorServiceFactory($location, $q) {
return new AuthInterceptorService($location, $q);
}
}
AuthInterceptorService.$inject = ['$location', '$q'];
angular.module('eucngts').factory('AuthInterceptorService', AuthInterceptorService.AuthInterceptorServiceFactory);
}
Когда я обновляю его до:
module Services {
export class AuthInterceptorService {
$location: ng.ILocationService;
$q: ng.IQService;
constructor($location, $q) {
var self = this;
self.$location = $location;
self.$q = $q;
}
//..
static AuthInterceptorServiceFactory($location, $q) {
return new AuthInterceptorService($location, $q);
}
}
AuthInterceptorService.AuthInterceptorServiceFactory.$inject = ['$location', '$q'];
angular.module('eucngts').factory('AuthInterceptorService', AuthInterceptorService.AuthInterceptorServiceFactory);
}
Он работает как ожидалось
AuthService
но это определяется только внутриService
и вы, похоже, нигде не вводите это?var Services;