Reputation: 827
I'm getting an angular unknown provider
error while trying to inject a constant
into a factory
that is being injected into a controller
.
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);
I've been adjusting inheritance order but it doesn't seem to be fixing this. Does anyone know what I'm doing wrong or how I might identify and address it?
EDIT: Commenting out the declaration of the constant (and manually replacing it's references with appropriate values) does allow the application to continue past this point, so in regards to templateResolutionData.js
that's the only thing preventing its execution.
Upvotes: 2
Views: 2465
Reputation: 149
I have simplified your code and run it without error on fiddle
angular.module('main', ['webModule', 'serviceModule'])
.controller('testPageController', [
'$scope', '$http', 'templateResolutionDataService',
function($scope, $http, templateResolutionDataService) {
//contents
$scope.setting = templateResolutionDataService;
}
]);
(function(angular) {
'use strict';
angular.module('serviceModule', [
'webModule'
])
.factory('templateResolutionDataService', ['estimatingUtilitiesSettings',
function(estimatingUtilitiesSettings) {
var getSetting = function() {
return estimatingUtilitiesSettings.SourceKeys;
}
return getSetting();
}
]);
})(window.angular);
(function(angular) {
'use strict';
angular.module('webModule', [])
.constant('estimatingUtilitiesSettings', {
SourceKeys: {
'Template': 1,
'Part': 2
}
});
})(window.angular);
Upvotes: 2
Reputation: 21850
You have misnamed miEstimatingUtilitiesSettings
to EstimatingUtilitiesSettings
Upvotes: 0