Init order. Sqlite plugin. Execution order


Hello. This is driving me nuts.

I have this init code: ( $ionicPlatform,
                        databaseService) {
    $ionicPlatform.ready(function () {


         if(window.cordova && window.cordova.plugins.Keyboard) {
        if (window.StatusBar) {



The databaseService.initDB opens and populates the sqlite database.
Somehow the consolelogs inside initDB ends up execution after the ready method ended.
Render of the first view (menu/catalog) is wrong beacuse the database is not populated yet.
Is there a workaround for this? I just want ionic/sqlite plugin to execute in the order i wrote the sentences…
Is sqlite running on another thread?

Thanks in advance