You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to create a new project, but don't work the plugin, this is the error:
ionic.bundle.js:26794 TypeError: Cannot read property 'openDatabase' of undefined
at Object.crearDB (app.js:48)
at new networkCtrl (app.js:30)
at Object.invoke (ionic.bundle.js:17995)
at $controllerInit (ionic.bundle.js:23397)
at nodeLinkFn (ionic.bundle.js:22335)
at compositeLinkFn (ionic.bundle.js:21703)
at nodeLinkFn (ionic.bundle.js:22387)
at compositeLinkFn (ionic.bundle.js:21703)
at compositeLinkFn (ionic.bundle.js:21706)
at publicLinkFn (ionic.bundle.js:21583)(anonymous function)
This is my code
angular.module('starter', ['ionic', 'ngCordova'])
.run(startApp)
.controller('networkCtrl', networkCtrl)
.factory('databaseFtr', databaseFtr);
startApp.$inject = ['$ionicPlatform'];
function startApp($ionicPlatform) {
$ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
});
}
networkCtrl.$inject = ['$scope', 'databaseFtr'];
function networkCtrl($scope, databaseFtr) {
databaseFtr.crearDB();
}
databaseFtr.$inject = ['$cordovaSQLite'];
function databaseFtr($cordovaSQLite) {
return {
crearDB: function() {
var db;
db = $cordovaSQLite.openDB({
name: "mydata.db",
location: 'default'
});
}
}
}
Image show the plugin install
The text was updated successfully, but these errors were encountered:
The problem is that your app does not wait for the deviceready event before attempting to open a database. This is a common problem with Angular controllers and I already documented this as a pitfall.
I will document the "cannot read property" error as a sign of this pitfall when I get a chance.
I try to create a new project, but don't work the plugin, this is the error:
This is my code
Image show the plugin install
The text was updated successfully, but these errors were encountered: