0
這是代碼的部分我已經查明,以引起問題的對象:cordovaSQLite不工作,錯誤:未定義不是(評價「n.transaction」)
angular.module('starter.controllers', []).controller('StudentsCtrl', function ($scope, $cordovaSQLite) {
var query = "SELECT id, student_id, username FROM students";
var users = [];
$cordovaSQLite.execute(db, query).then(function (data) {
$.each(data, function(i, item) {
users.push(item);
});
});
$scope.users = users;
});
我已經包括必要的文件爲$cordovaSQLite
工作。以上代碼位於www/js/controllers.js
之內,作爲默認Ionic選項卡式項目的一部分。 $cordovaSQLite
工作正常的www/js/app.js
內,也是在www/js/controllers.js
另一部分工作正常,但上面的代碼段返回我這個錯誤:
0 610246 error Error: undefined is not an object (evaluating 'n.transaction')
更新:看來,$cordovaSQLite
等於undefined
在這裏這個功能,但我不確定爲什麼會發生這種情況。
就像一個魅力。感謝你給我的代碼,也爲了解釋它! :d – think123