0
我有一個服務創建這樣:Angularjs未知服務提供商
(function() {
'use strict';
module.exports = siteAuthService;
angular
.module('authSite', [])
.factory('siteAuthService', ['$q', '$http', 'Requester', 'tsModulesService', siteAuthService]);
function siteAuthService($q, $http, Requester, tsModulesService) {
var factoryDefinitionObject = {
getUserByEmail: getUser,
createUser: createSiteUser,
recoverPassword: recoverPassword
};
return factoryDefinitionObject;
...
}
})();
我所在的地方試圖注入該服務控制器:
(function() {
'use strict';
angular
.module('formOrderDialog')
.controller('FormOrderDialogController', FormOrderDialogController)
.filter('getById', getById)
;
FormOrderDialogController.$inject = ['tsModulesService', '$scope', '$q', '$http', '$uibModalInstance', 'params', '$filter', 'Requester', 'dateHelpers', '$translate', 'alertService', '$uibModal',
'SaleLineFactory', 'tsPrintSelectService', 'tsPrintService', 'EntrySectorService', 'uiGridConstants', 'confirmationDialogService', 'siteAuthService'];
function FormOrderDialogController(tsModulesService, $scope, $q, $http, $uibModalInstance, params, $filter, Requester, dateHelpers, $translate, alertService, $uibModal,
SaleLineFactory, tsPrintSelectService, tsPrintService, entrySectorService, uiGridConstants, confirmationDialogService, siteAuthService) {
...
...
}
})();
而且模塊:
(function() {
'use strict';
const module = angular
.module('formOrderDialog', [])
;
})();
但我得到一個Error: [$injector:unpr] Unknown provider: siteAuthServiceProvider <- siteAuthService <- FormOrderDialogController
我也試過require("../../services/siteAuthService");
它在formOrderDialog模塊中,但還是不能注入它。
加上一個很好檢測 – Sajeetharan
這是問題,謝謝。 – tammy