Access injectable value to SubModule when importing it in App Module

前端 未结 1 918
花落未央
花落未央 2021-01-25 03:38

Okay, so, here\'s some context...

I\'ve got a feature module that requires a string value to be passed to its forRoot static method when imported in a

1条回答
  •  抹茶落季
    2021-01-25 04:42

    Try define an injection token inside the module (MyModule in this case). And try using like this :

        // main.ts
    Env.getConfig$().subscribe(config => {
        platformBrowserDynamic([
          { provide: YourToken, useValue: config } // <- here
        ]).bootstrapModule(AppModule)
    });
    

    api doc sample implementation

    0 讨论(0)
提交回复
热议问题