You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Application-wide services should be defined in the root application-wide injector. In our case, because all feature modules are loaded lazily, they create their own child injectors, where e.g. our GitHubAPIService is registered.
There's a real risk that we'll have more than one instance of that service, one in the root injector, one created by child injector. It's not a big deal in our case, but it's not a good practice (as described in the doc in Angular Modules chapter.
Instead, we should create the CoreModule, which is imported by AppModule (and only there) and move single-use classes there.
The text was updated successfully, but these errors were encountered:
ryzy
changed the title
Move application-wide services from SharedModule to root module
Move application-wide services from SharedModule to CoreModule
Dec 23, 2016
Application-wide services should be defined in the root application-wide injector. In our case, because all feature modules are loaded lazily, they create their own child injectors, where e.g. our GitHubAPIService is registered.
There's a real risk that we'll have more than one instance of that service, one in the root injector, one created by child injector. It's not a big deal in our case, but it's not a good practice (as described in the doc in Angular Modules chapter.
Instead, we should create the CoreModule, which is imported by AppModule (and only there) and move single-use classes there.
The text was updated successfully, but these errors were encountered: