lmeijdam / angular-umd-dynamic-example

Angular UMD example of loading new modules dynamically
174 stars 55 forks source link

@NgModule static forRoot when implementing compileModuleAndAllComponentsAsync #18

Open paramoca opened 5 years ago

paramoca commented 5 years ago

Hello,

More than an issue I would like to ask if anyone has an idea on how to achieve the following:

In this part of the code where the UMD file is loaded and compiled (PlaygroundModule):

return this.compiler.compileModuleAndAllComponentsAsync(module[${moduleInfo.moduleName}]) .then(compiled => { console.log(compiled); return module; });

If I have a static forRoot in the module that I am loading (PlaygroundModule):

export class PlaygroundModule { static forRoot( config: OAuthModuleConfig = null ): ModuleWithProviders { return { ngModule: PlaygroundModule, providers: [ { provide: OAuthModuleConfig, useValue: config } ] }; }

Is there any way to set the values for that forRoot when compiling the code implementing compileModuleAndAllComponentsAsync as I would provide them at design time?

See below..

@NgModule( { declarations: [ AppComponent ], imports: [ ...... PlaygroundModule.forRoot({ resourceServer: { allowedUrls: ['http://www.angular.at/api'], sendAccessToken: false } }), providers: [], bootstrap: [AppComponent] })

export class AppModule { }