gothinkster / angular-realworld-example-app

Exemplary real world application built with Angular

Home Page:https://angular.realworld.how/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

sharikovvladislav opened this issue · 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.