I have read about some Angular 2 project architecture, but they are not my case.
My question is where to place shared service that is used across modules.
My project has multiple modules, for example: admin module
and user module
.
This this the structure:
app
|admin
| |- some admin components
| |- admin.module
|user
| |- some user components
| |- shared
| |- user.service
| |- user.module
The problem is: I want to retrieve user's information in some components of admin module. So, I import user service into admin module and place it in admin module provider.
I think that this is not a good practice.
I found this:
http://jasonwatmore.com/post/2016/08/16/angular-2-jwt-authentication-example-tutorial
But I don't know if it is good practice.
Should I place user.service
to app/_services
for common use? Should I create a services.module to initialize user.service, then, import service module to others module?
app
|_services
| |- user.service
|admin
| |- some admin components
| |- admin.module - import and set user.service to provider
|user
| |- some user components
| |- user.module - import and set user.service to provider
`