Angular ngmodule的负载配置

时间:2019-08-25 11:58:12

标签: angular configuration angular-module

我正在这样platformBrowserDynamic中加载配置数据:

 platformBrowserDynamic([{ provide: MyConfig, useValue: new MyConfig(data.config) }]) 

MyConfig是一门课程:

export class MyConfig {
  setting1: string;
  setting2: string;
  other: {}

  constructor(data: any) {
   this.setting1 = data.setting1;
   this.setting2 = data.setting2;
   this.other = data.other;
  }
}

我的MyCustomModule

    export function someFactoryTest() {
     debugger; //<--got debugger steps here
     return 'something';
    }

   export function initializeConfig(config: MyConfig) {
     debugger; //<--debugger does not steps here and no errors in console.
     return config.other;
    }

    @NgModule({
      imports: [
        MyOtherModule.forRoot(initializeConfig, someFactoryTest) //<-- I want to be able to pass my params here
      ],
    })
    export class MyCustomModule {}

我无法从MyConfig获取值,试图进行调试,但有趣的是,调试器根本不介入initializeConfig

您是否有办法解决这个问题?

0 个答案:

没有答案