I'm wondering about some AngularJS behaviour. I'm curious if AngularJS modules inherit the dependencies of other modules. Let's say i have this structure:
var PVNServices = angular.module('PVN.services', []);
PVNServices.factory('ItemService', ['$q', 'apiUrl', '$http', 'errorHandler', function($q, apiUrl, $http, errorHandler) {
return {
getAlert: function(alert_id, user_id, categorie_id) {
return $http({ method: 'get',
url: apiUrl + 'getAlert/',
params : {
'alert_id' : alert_id,
'user_id' : user_id,
'categorie_id' : categorie_id,
}
}).then(function(res){return res.result }, errorHandler);
}
}
}]);
var PVNControllers = angular.module('PVN.controllers', ['PVN.services']);
PVNControllers.controller('AppController', ['$scope', 'ItemService', function($scope, ItemService) {
$scope.getAlert = function(alert_id, user_id, categorie_id){
ItemService.getAlert(alert_id, user_id, categorie_id).then(function(alert){
$scope.alert = alert;
}
}
}]);
var PVNDashboard = angular.module('PVN', ['ngSanitize','ngMaterial','PVN.controllers'], function($interpolateProvider) {
$interpolateProvider.startSymbol('<<');
$interpolateProvider.endSymbol('>>');
});
PVNDashboard.run(function() {
moment.locale('nl');
});
<body class="" ng-app="PVN">
</body>
With this structure, would I be able to use the ItemService in the PVNDashboard module because it has the controllers as dependency which in turn has the services as a dependecy. And because of the ng-app being the PVN module will the configuration of the PVN module, moment.js locale in this example case. Also persist in the services because it's the first to run?