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 ...