I have a service created this way:
(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;
...
}
})();
And a controller where I am trying to inject this service:
(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) {
...
...
}
})();
And module:
(function() {
'use strict';
const module = angular
.module('formOrderDialog', [])
;
})();
But I am getting an Error: [$injector:unpr] Unknown provider: siteAuthServiceProvider <- siteAuthService <- FormOrderDialogController
I also tried to require("../../services/siteAuthService");
it in formOrderDialog module, but still can't inject it.
The service is declared in the 'authSite'
module, while the controller is declared in the 'formOrderDialog'
module. You need to inject the authSite
module in order to access the service from it.
const module = angular
.module('formOrderDialog', ['authSite']);