There is a project with 2 separate modules, .module('app') and .module('secondApp') . In the module. .module('app') I have a service, for validation of fields, now there is a need to add this service to .module('secondApp') . Is it possible to connect it to 2 modules in order not to make a copy of the service, but to use the existing one?

    2 answers 2

    To put the service in a separate module, connect this module depending on the other two, and then use the service from it.

       angular.module('MainApp', ['app', 'secondApp']);