0
Im新的IONIC和我需要使用ngCordova的幫助我能夠在我的app.js.上創建數據庫。但是我總是在嘗試時收到此錯誤消息訪問我的控制器上的數據庫「類型錯誤:無法調用未定義的方法 '的openDatabase'」IONIC上的SQLite「TypeError:無法調用未定義的方法'openDatabase'
下面是我的代碼:
Controller.js:
angular.module('app.controllers', ['ionic','ngCordova'])
.controller('loginCtrl', ['$scope', 'LoginService', '$ionicPopup', '$state','$cordovaSQLite',
function ($scope,LoginService,$ionicPopup, $state,$cordovaSQLite) {
$scope.data = {};
$scope.login = function() {
var db = null;
console.log("LOGIN user: " + $scope.data.username + " - PW: " + $scope.data.password);
LoginService.loginUser($scope.data.username, $scope.data.password).success(function(data) {
db = $cordovaSQLite.openDB("guards.db");
var query = "CREATE TABLE IF NOT EXISTS incident_list (id integer autoincrement primary key, complainant string , defendant string, details string, remarks string,incident_date datetime)";
runQuery(query,[],function(res) {
console.log("table created done");
}, function (err) {
console.log("table created done");
console.log(err);
});
$state.go('guardTrack.home');
}).error(function(data) {
var alertPopup = $ionicPopup.alert({
title: 'Login failed!',
template: 'Please check your credentials!'
});
});
}}])