angularjs - Cannot read property 'openDatabase' of undefined -
i'm using phonegap framework. js files loaded completely. i'm using following statement.
var db = window.sqliteplugin.opendatabase({ name: "mydb.db" }); but i'm getting error like:
typeerror: cannot read property 'opendatabase' of undefined any suggestion?
there points need known:
- database activity can done when
ondeviceready()method has fired for i’m going open database in
modules .run()method like:db = $cordovasqlite.opendb("my.db");
before writing line , make sure have added sqlite plugin , $cordovasqlite dependency added in project .
here example:
var db = null; var example = angular.module('starter', ['ionic', 'ngcordova']) .run(function($ionicplatform, $cordovasqlite) { $ionicplatform.ready(function() { if(window.cordova && window.cordova.plugins.keyboard) { cordova.plugins.keyboard.hidekeyboardaccessorybar(true); } if(window.statusbar) { statusbar.styledefault(); } db = $cordovasqlite.opendb("my.db"); $cordovasqlite.execute(db, "create table if not exists people (id integer primary key, firstname text, lastname text)"); }); }); hope work you. reference can use this:
Comments
Post a Comment