Cannot bootstrap with upgrade for multiple lazyloaded modules.
chikakow opened this issue · 0 comments
Based on the lazyloaded example of this repo, I created one more lazyloaded module.
So now my folders are like below.
js1 -> angularjs.module.ts and angularjsapp.ts js2 -> angularjs2.module.ts and angularjsapp2.ts
And setup everything in js2 to be just like js1. then do ng serve.
When you navigate to either one of lazyloaded module, it works fine but after that navigate to the second lazyloaded module, then you get error.
core.es5.js:1020 ERROR Error: Uncaught (in promise): Error: [ng:btstrpd] App already bootstrapped with this element '<body class="ng-scope">'
https://errors.angularjs.org/1.7.8/ng/btstrpd?p0=%26lt%3Bbody%20class%3D%22ng-scope%22%26gt%3B
Error: [ng:btstrpd] App already bootstrapped with this element '<body class="ng-scope">'
https://errors.angularjs.org/1.7.8/ng/btstrpd?p0=%26lt%3Bbody%20class%3D%22ng-scope%22%26gt%3B
at angular.js:138
at doBootstrap (angular.js:1941)
at Object.bootstrap (angular.js:1981)
at bootstrap (static.es5.js:52)
at static.es5.js:1328
at ZoneDelegate.invoke (zone.js:391)
at Object.onInvoke (core.es5.js:3890)
at ZoneDelegate.invoke (zone.js:390)
at Zone.run (zone.js:150)
at NgZone.run (core.es5.js:3821)
at resolvePromise (zone.js:831)
at resolvePromise (zone.js:788)
at zone.js:892
at ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.es5.js:3881)
at ZoneDelegate.invokeTask (zone.js:422)
at Zone.runTask (zone.js:195)
at drainMicroTaskQueue (zone.js:601)
I think I should put something like unbootstrap the previous module, when it goes to the second one before that bootstrap. So it will be in the state just like before any of lazyloaded module was clicked.
So right before this code.
upgrade.bootstrap(document.body, [module.name]);
setUpLocationSync(upgrade);
but I don't know how to do such "unbootstrap" thing.
Please let me know how to do this. This should be pretty common case for many angular apps.
I have this issue example in my forked repo and branch called 2LazyModules.
https://github.com/chikakow/upgrade-book-examples
Thank you.