W3cubDocs

/Angular 11

APP_INITIALIZER

const

A DI token that you can use to provide one or more initialization functions.

See more...

const APP_INITIALIZER: InjectionToken<(() => void)[]>;

See also

Description

The provided functions are injected at application startup and executed during app initialization. If any of these functions returns a Promise, initialization does not complete until the Promise is resolved.

You can, for example, create a factory function that loads language data or an external configuration, and provide that function to the APP_INITIALIZER token. The function is executed during the application bootstrap process, and the needed data is available on startup.

© 2010–2021 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v11.angular.io/api/core/APP_INITIALIZER