Hi Guys,
I have written an ionic app which needs SQL Lite to function however whichever page I choose to load first always has its Sqlite broken(it doesn’t execute) I’ve tried using platform ready but thats not making any difference.
Any suggestions?
Thanks
For those having the same issue the only way to solve it is to wrap your database call in a $timeout set to about 400 milliseconds.
what about device ready?
In my experience … platform ready does not always fire on device (but works perfectly in browser)
I was using, would you recommend using device ready instead?
$ionicPlatform.ready(function() {
//database stuff }
Thanks,
@davidhogan
defined your database inside device ready function
document.addEventListener('deviceready', onDeviceReady, false);
/ / Cordova is ready
function onDeviceReady() {
var db = window.sqlitePlugin.openDatabase({name: "my.db"});
db.transaction(function(tx){
tx.executeSql("CREATE TABLE TABLE_NAME IF NOT EXISTS(id int primary key)", []);
});
}
I use them both … if in browser I use $ionicplatform and on device I use device ready
I think all you need is device ready … but have not tried it 