angular2 dynamically load module

201 views Asked by At

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);
   });
1

There are 1 answers

0
Josephat Ogwayi On

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