angular-plugin-architecture icon indicating copy to clipboard operation
angular-plugin-architecture copied to clipboard

Can I use Router to loading plugins?

Open jaichandra opened this issue 6 years ago • 2 comments

Thanks for putting this demo app. I was looking into other example for loading plugins dynamically and had the same issue with buildOptimzer not working. Stumbled across this at the right moment.

Could you comment on how to make router work with this example. Can I wire RouterModule like in https://github.com/lmeijdam/angular-umd-dynamic-example demo with this?

jaichandra avatar Sep 22 '19 14:09 jaichandra

Would be interested in an example too. I want to inject new routes from a plugin module to the main nav and they should behave like "normal" modules.

Disane87 avatar Nov 19 '19 08:11 Disane87

Try this. Load ModuleFactory and Reset router config.

const routerConfig = this.router.config;
this.pluginLoader.load('plugin').then(moduleFactory => {
   routerConfig[0].children.push({
      path: 'test',
      loadChildren: () => moduleFactory
   });
   this.router.resetConfig(routerConfig);
});

Hope this helpful.

HollyLiang avatar Dec 31 '19 06:12 HollyLiang