I know that in Angular2, services provided by a module are available to other modules and should be provided only once.
I have a lazy-loaded MessengerModule which imports a MessengerService. I have also a HeaderModule which needs this service only for updating messages notifications.
I see two ways:
- Provide MessengerService at the AppModule level
- Provide MessengerService in MessengerModule. Import MessengerModule in HeaderModule.
In 1, it is annoying to "break" the MessengerModule by removing its logical service. In 2, I will lose the lazy loaded feature of MessengerModule which is quite big. As HeaderModule is eager loaded, Messenger will be as well right?
It seems the best choice is to provide the service at the main level. Which are your suggestions?