Is there any advice out there for a newbie about integrating ngCordova, and the SQLlite plugin into a new ionic project?
I have added ngCordova into my project as documented, and have included the plugin using the cordova command line utility.
The issue I’m having is in testing my app, when using ionic serve I get a number of different issues depending on what I try:
Doing nothing with the sqlite js file : I get an error stating stating that the sqlitePlugin is undefined.
If I get a copy of the sqliteplugin.js file from my plugins directory, and copy it to my lib folder, then reference it in the index.html file : I get an issue with cordova not being defined :- is this becasue I am using ionic server rather than ionic emulate android/ios?
I’ve been playing with this on and off for a week now and I’m not getting anywhere, if anyone has an example I would appreciate reading through it.
If you want to use ngCordova, you need to test it with a device or test on emulator.
ionic serve simply starts a web server.
During development you can use websql with ionic serve. Below is the difference between cordova sqllite and websql.
Use websql during development then switch to cordova sqllite plugin when running on device.
Accessing db with sqllite plugin
var db = window.sqlitePlugin.openDatabase({name: “my.db”});
Accessing db with websql
var db = window.openDatabase(“my.db”, “1.0”, “my.db”, 200000);
I have used window.openDatabase in the past, out of interest do you know if there is anyway of detecting if ionic serve is being used so that the db creation method may be switched?