How to wait for a promise in a Run block in AngularJS?

I guess that the only solution is manually bootstrap your application. Maybe you can find some help in this question Delay Angular App Initialization and in this small article Manually bootstrapping AngularJS for asynchronous loading in Internet Explorer.

As stated in the previous article, to do a manual bootstrap:

angular.element(document).ready(function() {
  angular.bootstrap(document, ["myApp"]);
});

Be sure to remove all the refences of ng-app in your HTML to stop the auto bootstrapping.


You may want to look at this SO question - it shows how to initialize an AngularJS service with asynchronous data.

Here is a plunkr example from that question showing the use of AngularJS services like $http to load the configuration and then do further initialization.

This answer has a great explanation and shows an example of waiting for the DOM to load like this (plunkr example from that answer is here) :

angular.element(document).ready(function() {
  angular.bootstrap(document);
});

As I commented would put it here

You may try manual bootstrap

<script> 
   angular.element(document).ready(function() {
      angular.bootstrap(document); 
   });
</script>

Of cause in this case you cannot use controllers and angular way of getting data. I think you would have to load your data by jQuery, bootstrap your angular in jquery callback and then init your scope variable with data you got from jquery.

Tags:

Angularjs