我在嘗試將constant
注入正在注入controller
的factory
時出現角度unknown provider
錯誤。AngularJS獲取未知供應商錯誤將一個常數注入工廠
angular.js:13920 Error: [$injector:unpr] Unknown provider: estimatingUtilitiesSettingsProvider <- estimatingUtilitiesSettings <- templateResolutionDataService
app.js:
angular
.module('main', [
'ngResource'
, 'angulartics'
, 'angulartics.appinsights'
, 'envModule'
, 'gettext'
, 'webModule'
, 'serviceModule'
])
.controller('testPageController', [
'$scope'
, '$http'
, '$resource'
, 'envModule'
, 'gettext'
, 'templateResolutionDataService'
, 'profileTemplateResolutionDataService'
, 'templateResolutionDataWithMultipleTemplatesService'
, 'partResolutionDataService'
, 'featureToggleService'
, 'recommendedResolutionDataService'
, 'profiledResolutionDataService'
, function ($scope, $http, $resource, envModule, gettext
, templateResolutionDataService
, profileTemplateResolutionDataService
, templateResolutionDataWithMultipleTemplatesService
, partResolutionDataService
, featureToggleService, recommendedResolutionDataService
, profiledResolutionDataService) {
//contents
}]);
templateResolutionDataService.js:
(function (angular) {
'use strict';
angular
.module('serviceModule', [
'webModule'
])
.factory('templateResolutionDataService', [
'gettext'
, 'estimateUtilitiesExtensionService'
, 'partResDataServiceSettings'
, 'estimatingUtilitiesSettings'
, function (gettext, estimatingUtilitiesService
, partResDataServiceSettings, estimatingUtilitiesSettings) {
}
]);
})(window.angular);
webModule.js:
(function (angular) {
'use strict';
angular
.module('webModule', [
'ng'
, 'ngResource'
,'miEnvironment'
,'gettext'
,'analyticsFilters'
,'touchEvents'
,'flyoutModule'
])
.constant('estimatingUtilitiesSettings', {
SourceKeys: {
'Template': 1
,'Part': 2
}
});
})(window.angular);
我一直在調整繼承順序,但它不似乎沒有解決這個問題。有誰知道我做錯了什麼,或者我可能如何識別和解決它?
編輯:註釋掉不變的聲明(手動用適當的值替換它的引用)確實允許應用程序繼續過去的這一點,所以在關於templateResolutionData.js
這是防止其執行的唯一的事情。
運行它不應該是'miEstimatingUtilitiesSettings',而不是'estimatingUtilitiesSettings'? –
我搞砸了複製它,mi不應該在那裏,不在代碼中 –
是否所有的模塊定義都正在執行?由於沒有腳本標記或語法錯誤,從未執行代碼時發佈的錯誤很常見。 – tcooc