angular-plugin-architecture
angular-plugin-architecture copied to clipboard
Can I use Router to loading plugins?
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?
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.
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.