I came accross this situation where i need to load the whole angular application from another script file. The idea was to get the version of the application from the backend and as i get the version, i have to load the angular app.
So right now, i have something like <script src="versionLoader.js">. And inside the file, i am trying to load the whole angular app.
$.ajax({
url: "url",
success: function(version){
versionFiles(version.app_version);
},
});
var files=[angularFiles];
var versionFiles=function(version){
for(var i=0; i<files.length; i++){
var scriptElem= document.createElement("script");
scriptElem.src="scripts/"+files[i]+"?v="+ version;
document.body.appendChild(scriptElem);
}
}
where versionFiles consist of initailization of the angular app(app.js) and every other component. I get the element added to document like <script src="scripts/services/tag.js?v=0.7"></script> but the app fails to load with module not found error.
This might be silly of me. Will appreciate it so much :).
angular.bootstrap(elm, [module_name])