angularjs defining services for the same module in different files angularjs defining services for the same module in different files angularjs angularjs

angularjs defining services for the same module in different files


This is from the docs:

Beware that using angular.module('myModule', []) will create the module myModule and overwrite any existing module named myModule. Use angular.module('myModule') to retrieve an existing module.

Found here:https://docs.angularjs.org/guide/module


This is possible, however will be error prone, hence not recommended

Make small modification to what you are already doing

Just do not re-declare the module variable in other files other than service1.js or put the module definition to a file of its own and include these JS file in the order of Module.js, services.js, directive.js then it will work