How to wait for a promise in a Run block in AngularJS?
angularjs
Solution
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.
Problem
I really need some data to be loaded before bootstrapping angular. For this reason I've created a `run` block/ Within this `run` block I call a method on a service which load some data from the server. Since this is a async call, JavaScript gets further with execution, which results in some undefined objects in my app. I am working with routes, but it is not an option to work with the `resolve` property. Could someone provide a solution on how to wait for a promise to be ready in the `run` block? EDIT: Thanks to the given answers, I have solved it by manually bootstrapping angular: ``` $(document).ready(function () { $.ajax('/Data/GetDropdownData', {type:'POST'}).done(function (response) { app.run(['ListService', function (ListService) { ListService.setData(response); }]) angular.bootstrap(document, ["sma"]); }) }) ```