gothinkster/angular-realworld-example-app

Why don't you use providedIn Injectable feature for services in eagerly loaded modules?

sharikovvladislav opened this issue · 0 comments

Example:

https://github.com/gothinkster/angular-realworld-example-app/blob/master/src/app/home/home-auth-resolver.service.ts#L8

HomeAuthResolver is provided in HomeModule. HomeModule is eagerly loaded to AppModule.

I am talking about: https://angular.io/api/core/Injectable

https://angular.io/guide/architecture-services

Registering the provider in the @Injectable() metadata also allows Angular to optimize an app by removing the service from the compiled app if it isn't used.