Here is a example code: I have following code at the end of html body
<script type="text/javascript">
var js = document.createElement("script");
js.src = "forms/dynamicForms/sampleFormController.js";
document.body.appendChild(js);
angular.bootstrap(document, ['MyApp']);
</script>
When I run my app, sampleFormController is not found, if I inspect body tag in Chrome, script is added as a child tag to body tag.
where as when I modify code and add timeout it works
<script type="text/javascript">
var js = document.createElement("script");
js.src = "forms/dynamicForms/sampleFormController.js";
document.body.appendChild(js);
setTimeout(myFunction, 2000);
function myFunction() {
angular.element(function() {
angular.bootstrap(document, ['MyApp']);
});
}
</script>
Is there a way to make my first code to work without adding timeout?