Click here to Skip to main content
14,238,047 members
Rate this:
Please Sign up or sign in to vote.
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100