Angular injectors' hierarchy

Angular contains a unique platform injector that is populated when the application is bootstrapped. This injector contains services used by the framework itself, and other services that the developer can add in main.ts where the application is bootstrapped. The code scaffolded by the Visual Studio Angular template adds a service that returns the application base URL, as follows:

export function getBaseUrl() {  return document.getElementsByTagName('base')[0].href;}const providers = [  { provide: 'BASE_URL', useFactory: getBaseUrl, deps: [] }];platformBrowserDynamic(providers).bootstrapModule(AppModule)  .catch(err => console.log(err));

In this case, the service is indexed by the string token BASE_URL. The singleton ...

Get Hands-On TypeScript for C# and .NET Core Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.