Use providedIn for the Angular Service registration to reduce bundle size

Share this video with your friends

Send Tweet

As we've seen in my course on Angular Service Injection with the DI there are different ways to register a service with Angular's Dependency Injector. The major approaches (as of Angular v8+) is to either register the service on the NgModule providers array, or to directly use the @Injectable({ providedIn: 'root' }) decorator.

In this lesson we're going to specifically look into the impact of those two methods to the final bundle size

More details can also be read in one of my recent blog posts