Ionic and SQLite help

I’m building an app that saves login credentials to a SQLite database, so after the first login, user can use the app even offline and sync data later when online. it’s working perfectly on browser, but on emulator and on device I get this “TypeError: Cannot read property ‘username’ of undefined”

can you gave my the code ? You can try to delete the app on you’re device and run it again

if ( window.cordova ) {
BD = $cordovaSQLite.openDB({ name:“database.db”, location: ‘default’ }); //device
} else {

  BD = window.openDatabase("database.db", '1', 'database', 1024 * 1024 * 100); // browser
}

it’s working fine with window.openDatabase on chrome, but on device it does not.

had that problem wrapping it with $ionicPlatform.ready(function() { }) fixed it. worked fine on android but other platforms where the real problem

1 Like

How did you fix it? I’m stuck here.

Put ur code inside the function I put there’s

I am using $ionicPlatform.ready(function() { })
And it still does not work on devices. browser is ok.

make sure you inject ‘$cordovaSQLite’ into your controller

I sincerely wish that was the problem, but no, it’s already done since before I started this topic. =(