小编Sam*_*ams的帖子

Angular 导入的模块不等待 APP_INITIALIZER

auth0/auth0-angular我正在尝试在 Angular 11 应用程序中使用该库。

我正在关注动态加载配置部分。

它提供了此示例应用程序模块代码:

// app.module.ts
// ---------------------------
import { AuthModule, AuthClientConfig } from '@auth0/auth0-angular';

// Provide an initializer function that returns a Promise
function configInitializer(
  handler: HttpBackend,
  config: AuthClientConfig
) {
  return () =>
    new HttpClient(handler)
      .get('/config')
      .toPromise()
      .then((loadedConfig: any) => config.set(loadedConfig));   // Set the config that was loaded asynchronously here
}

// Provide APP_INITIALIZER with this function. Note that there is no config passed to AuthModule.forRoot
imports: [
  // other imports..

  HttpClientModule,
  AuthModule.forRoot(),   //<- …
Run Code Online (Sandbox Code Playgroud)

auth0 angular

16
推荐指数
1
解决办法
9675
查看次数

标签 统计

angular ×1

auth0 ×1