Sqlite Plugin and Ionic/Angularjs

I came across a little problem with the sqlite plugin.

When my App starts i get following execution order:

**** app.config.routers
**** app.run 
***** DB INIT
**** Controller: First Page/View
**** Platform is ready! 

Thats how i would like it, but this only works with webSQL and not sqlite Plugin because at this time when App.run is executed the plugins are not loaded yet.

im using the wrapper from jgoux: https://gist.github.com/jgoux/10738978
I just changed a part of the factory to this

if (window.navigator.simulator) {
   self.db = openDatabase(DB_CONFIG.name, DB_CONFIG.version, 'database', -1);
} else {
   self.db = window.sqlitePlugin.openDatabase({ name: DB_CONFIG.name });

if i want this to run i have to call DB.init() in $ionicPlatform.ready so I’m sure cordova and plugins are loaded.

but then DB init is run after First Controller.

**** app.config.routers
**** app.run 
**** Controller: First Page/View
**** Platform is ready! 
***** DB INIT

in my First Controller i have this code to get all data for this view:

Table.all().then(function(data) {
     $scope.data = data;

do you have some suggestions/experience or would using webSQL be enough?

If anyone has the same problem, i did solve this with waiting for cordova to fire ready and then starting angular Apps.

todo so i removed the ng-app and added this to index.html:

<script type="text/javascript">
   document.addEventListener('deviceready', function onDeviceReady() {
      angular.bootstrap(document, ['myApp']);
   }, false);

this will manually trigger angularjs.

I’m running into this same problem but when I add your solution my app doesn’t work. Any ideas?

checkout the library angular-wsql I coded for solving manipulations upon WebSQLite. This is basically Active record which works together with angularJS and Ionic.

it is also available via bower

bower install angular-wsql