代码之家  ›  专栏  ›  技术社区  ›  Jake Smith

ngmodule decorator中使用的角库模块pass配置

  •  1
  • Jake Smith  · 技术社区  · 6 年前

    我创建了一个身份验证角度库项目来抽象我正在使用的提供者。由于Angular库项目不支持环境配置,因此我正在寻找一种方法,使正在使用的应用程序项目能够将配置传递给库项目。我见过有人建议 forRoot 方法,但我不确定如何在 NgModule 身份验证模块的装饰器。例如:

    @NgModule({
      imports: [
        ProviderAuthModule.initAuth({
          issuer: config.issuer,
          redirectUri: `${config.rootURI}/implicit/callback`,
          clientId: config.clientID,
          responseType: config.responseType
        })
      ],
      declarations: [],
      exports: []
    })
    export class TdAuthenticationModule {
      static forRoot(config: ?) {
        return {
          ngModule: TdAuthenticationModule,
          ?
        };
      }
    }
    

    我见过人们使用 InjectorToken 能够将配置传递给库项目,然后这些项目可以被注入到该库的服务和组件中,但我不知道是否有方法使用该模块的decorator中传递给库模块的配置。

    这可能吗?

    0 回复  |  直到 6 年前