- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的代码中 $cordovaSQLite.execute 函数在 .run 函数中运行良好,但在我的 Controller 中出现错误。我不知道我做错了什么,我已经包含了所有必需的插件并按照这个非常好的示例的步骤进行操作 https://blog.nraboy.com/2014/11/use-sqlite-instead-local-storage-ionic-framework/
var db = null;
var myapp=angular.module('starter', ['ionic','btford.socket-io','LoginCntrl','SlideCntrl','app','ChatCntrl','ngCordova','ngCordova.plugins.sqlite'])
.run(function($ionicPlatform,$cordovaSQLite) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
console.log("The application is resuming from the background");
db = $cordovaSQLite.openDB({ name: App_DB_Name });
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS people (id integer primary key, firstname text, lastname text)");
var query = "SELECT firstname, lastname FROM people WHERE lastname = ?";
$cordovaSQLite.execute(db, query, ["pruthvi"]).then(function(result) {
if(result.rows.length > 0) {
console.log("SELECTED -> " + result.rows.item(0).firstname + " " + result.rows.item(0).lastname);
alert("SELECTED -> "+ result.rows.item(0).firstname + " " + result.rows.item(0).lastname)
} else {
console.log("No results found");
}
}, function (err) {
console.error(err);
});
// $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS "+ App_DB_Table_Login_Name +"(id integer primary key, login_username text, login_password text)");
console.log("success");
});
});
myapp.controller('IndexController', ['$scope','$rootScope', function($scope,$rootScope,$cordovaSQLite, $ionicPlatform){
var query = "SELECT firstname, lastname FROM people WHERE lastname = ?";
$cordovaSQLite.execute(db, query, ["pruthvi"]).then(function(result) {
if(result.rows.length > 0) {
console.log("SELECTED -> " + result.rows.item(0).firstname + " " + result.rows.item(0).lastname);
alert("SELECTED -> "+ result.rows.item(0).firstname + " " + result.rows.item(0).lastname)
} else {
console.log("No results found");
}
}, function (err) {
console.error(err);
});
}]);
TypeError: $cordovaSQLite.execute is not a function at new (app.js:105) at Object.invoke (ionic.bundle.js:13277) at extend.instance (ionic.bundle.js:17826) at nodeLinkFn (ionic.bundle.js:16936) at compositeLinkFn (ionic.bundle.js:16368) at compositeLinkFn (ionic.bundle.js:16372) at publicLinkFn (ionic.bundle.js:16243) at ionic.bundle.js:10462 at Scope.$eval (ionic.bundle.js:24673) at Scope.$apply (ionic.bundle.js:24772)(anonymous function) @ ionic.bundle.js:21157 console-via-logger.js:173 No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.(anonymous function) @ console-via-logger.js:173 console-via-logger.js:173 The application is resuming from the background console-via-logger.js:173 OPEN database: db_demoionic.db 2console-via-logger.js:173 new transaction is waiting for open operation console-via-logger.js:173 success console-via-logger.js:173 DB opened: db_demoionic.db console-via-logger.js:173 No results found console-via-logger.js:173 No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin. 3console-via-logger.js:173 No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.
最佳答案
看起来 myapp.controller(...)
调用中的代码是在启动时执行的。如果 Controller 连接到页面主体之类的东西,它还必须等待 Ionic/ngCordova 准备好(例如使用 $ionicPlatform.ready(...)
)。
关于angularjs - $cordovaSQLite.execute 不是 ionic 中的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33141209/
cordovaSQLite 是否有批量插入功能?我有很多数据,我想将其保存在 sqlite 数据库中。 我现在的代码是 var query = "INSERT INTO Card (CardId, C
在我的代码中 $cordovaSQLite.execute 函数在 .run 函数中运行良好,但在我的 Controller 中出现错误。我不知道我做错了什么,我已经包含了所有必需的插件并按照这个非常
尝试遵循使用 SQL lite 的示例,但遇到了困难。 示例说,将 ngCordova 包含在 app.js 中: angular.module('starter', ['ionic', 'start
目前我使用 Angularjs 框架开发 cordova 应用程序。我想获得值(value)返回 $cordovaSQLite.execute() 函数。通常我使用 .then(result()) 获
我目前正尝试在我的应用程序中实现 ngCordova SQLite 插件,但尚未生成有效的解决方案。我关注了Nic Raboy's blog post关于如何将 SQLite 插件与 Ionic 项目
这是我确定导致问题的代码部分: angular.module('starter.controllers', []).controller('StudentsCtrl', function ($scop
我是一名优秀的程序员,十分优秀!