wishtack / wishtack-steroids

Frontend on Steroids: Reactive Component Loader, RxJS Scavenger...
https://wishtack.io
MIT License
96 stars 16 forks source link

Angular 10? #213

Open mattiLeBlanc opened 4 years ago

mattiLeBlanc commented 4 years ago

Hi,

I am looking at loading Modules dynamically in my child routing. I am trying out this package but I am getting some errors that the module can't be found on Angular 10. I tried to create a Stackblitz version so I can show you what I am trying to do but when I install this package on Stackblitz, I get the error ngcc failed to run on @wishtack/reactive-component-loader@1.1.2..

Anyway, what I am trying in my main app-routing.module file is the following:

const routes: Routes = [
  {
    path:  '**',
    resolve: {
      template: TemplateResolver
    },
    children: [
      {
        path: '',
        component: TemplateLoaderComponent
      }
    ]
  }
];

The TemplateResolver will receive a recipe with instructions on what template needs to be loaded, which should be decided in the TemplateLoaderComponent.

In the TemplateLoaderComponent I would like to be able to load Module A, Module B or Module C based on what the recipe returns.

Then these Modules will have their own routing file with a root path ('') and a 'thankyou' path.

Is that possible with this package?

Alternatively I would do it in Angular using a load childeren construction like:

const routes: Routes = [
  {
    path:  '**',
    resolve: {
      template: TemplateResolver
    },
    children: [
      {
        path: 'moduleA',
       loadChildren: () => import('./modules/oduleA/moduleA.module').then(m => m.ModuleAModule) 
      },
     {
        path: 'moduleB',
       loadChildren: () => import('./modules/oduleA/moduleA.module').then(m => m.ModuleAModule) 
      },
     {
        path: 'moduleC',
       loadChildren: () => import('./modules/oduleA/moduleA.module').then(m => m.ModuleAModule) 
      }
    ]
  }
];

but I don't want to have to be come rootpath/moduleA. It should just be rootpath and then based on the Template Resolver it loads either ModuleA, B, or C.