Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I use Router to loading plugins? #13

Open
jaichandra opened this issue Sep 22, 2019 · 2 comments
Open

Can I use Router to loading plugins? #13

jaichandra opened this issue Sep 22, 2019 · 2 comments

Comments

@jaichandra
Copy link

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?

@Disane87
Copy link

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.

@HollyLiang
Copy link

HollyLiang commented Dec 31, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants