Wait to bootstrap angular until after promise fufilled in .run

Hey Guys,

So I am using the SQLite Cordova plugin and I am having an issue with angular bootstrapping before a database is set up. This is because I am using a SQLiteService.init(); to create the database in .run which uses a promise. The issue is the app bootstraps before the promise is fulfilled and a controller makes a database query before the database is set up causing a white screen. This only happens the first time the app is started but it is still a big issue.

Is there a way to not leave .run until the promise is fulfilled? I could make another version of the runQuery function that is not promise based but am curious if there are any other solutions. Code is below.


Thanks for any help or suggestions

have you tried $q.all()?

So lets look at this example.

 people.ready = $q.all([
  return people;

Here I’m calling people.add() and when that is ready, I can execute my in my controller.

  people.ready.then(function() {
   //Anything that needs to run after people.add() is finished

@mhartington This worked very well! Thank you!