My dilemma lies in creating a dynamic single page application that can load and unload AngularJS apps on demand within a designated "main content" section when selecting different menu options.
Despite my efforts, I am consistently encountering the ng:btstrpd
error whenever attempting to utilize the angular.bootstrap
function.
The apps are loaded using the following code snippet:
var mainContent = document.getElementById('main-content');
window.loadApp = function(modules) {
angular.bootstrap(mainContent, modules);
}
For reference, here is a jsfiddle link: http://jsfiddle.net/010b62ry/
I have experimented with removing and reinserting the DOM element, but encountered unexpected results such as duplicates. It appears that the modules are not being properly unloaded, as indicated by the presence of numerous <!-- ngView: -->
comments.
Do you have any insights on how to implement this functionality successfully? Bonus points if the memory is effectively released when transitioning between applications.
Additionally, it is crucial for the modules to operate independently and manage their own routes, especially since some may be developed by external parties with no access to the source code of the main application. The goal is to initiate these modules as self-sufficient Angular applications.