November 2019
Beginner
804 pages
20h 1m
English
When Angular bootstraps, it creates a default application-wide injector called the root application injector, which is linked to AppModule (that is, the root application module). By default, service providers are registered in it.
To register a service globally (that is, to make it injectable anywhere in your application), you can use the providedIn: 'root' property of the @Injectable decorator, as we did in the previous section. This will register the service in the root application injector.
To be thorough, you should know that Angular's DI framework defines a tree of injectors, which is somewhat akin to the change detection tree. Similarly, the injector tree reflects and lies next to the ...
Read now
Unlock full access