简体   繁体   中英

angular2 dynamically load module

I have an application running and in one of my components i want to have a button and on click i want to load another module from another file and bootstrap it. It's working but i get EXCEPTION: Expected to not be in Angular Zone, but it is! and i have no idea why and how to fix it. here is my code:

index.html:
<app1></app1>
<app2></app2>

and on click i have this:

return System.import('../secondapp.ts').then((comp: any) => {
        platformBrowserDynamic().bootstrapModule(comp.default);
   });

The error is as a result of the bootstrap loading more than once. Its a restriction by Angular. You'll need to dispose the component before bootstrapping it again

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM