填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

APP_INITIALIZER

An injection token that allows you to provide one or more initialization functions. These function 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.

查看"说明"...

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

说明

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. That way, the function is executed during the application bootstrap process, and the needed data is available on startup.