Click here to Skip to main content
15,888,109 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

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

An angular (7.2) UMD NgModule is being loaded from a main angular application.

The code that is loading the UMD module is:

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


If I have a static forRoot in the module that I am loading to init it:

export class PlaygroundModule
{
  static forRoot
  (
      config: ModuleConfig = null
  ): ModuleWithProviders 
{
  return 
  {
    ngModule: PlaygroundModule,
    providers: 
    [
        { provide: ModuleConfig, 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.codeca.au/api']
      setToken: false
   }
  }),
providers: [],
bootstrap: [AppComponent]
})

export class AppModule
{ }


Thanks

What I have tried:

I haven't found any site that could point me to the right direction yet.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900