use*_*804 2 angularjs ionic-framework
非常感谢你们在很多方面帮助我们的所有教程.请问,虽然我是角度/离子新手,但我手头有问题需要解决.
1)我有一个表格,其中包含几个输入来收集个人信息,如姓名,性别,DOB,职业等.在表格的底部,我有图像标签和一个按钮分别显示和捕捉图像.我能够捕获并显示捕获的图像.
问题陈述:
1)我想将所有个人信息(包括捕获的图像)保存在本地存储中.为什么?因为网络不好
2)我想检索保存的信息和图像并上传到远程服务器.
如果你能用你想要的简单而简短的教程来说明这一点,我将非常感激.再次感谢.
您可能需要考虑使用Cordova sqlite存储.链接
去做吧,
通过以下方式将插件安装到离子项目文件夹中:
cordova plugin add https://github.com/brodysoft/Cordova-SQLitePlugin.git
Run Code Online (Sandbox Code Playgroud)
获取ng-cordova.min.js并添加到ur javascript目录中,将以下代码行添加到index.html中.
<script src="<your folder>/ng-cordova.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
通过以下方式注入角度模块(app.js):
angular.module('starter', ['ionic', 'ngCordova'])
Run Code Online (Sandbox Code Playgroud)
通过以下方式创建数据
.controller('YourController', function(....., $cordovaSQLite){
var db = $cordovaSQLite.openDB("database.db");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS form (id integer primary key, name text, address text, telephone text)");
Run Code Online (Sandbox Code Playgroud)
插入示例:
$scope.insert = function(name, text, telephone) {
var query = "INSERT INTO form (name, text, telephone) VALUES (?,?,?)";
$cordovaSQLite.execute(db, query, [name, text, telephone]).then(function(res) {
console.log("success!");
}, function (err) {
console.error(err);
});
}
Run Code Online (Sandbox Code Playgroud)
然后,您的图像文件可以存储为blob并享受乐趣!(:
| 归档时间: |
|
| 查看次数: |
2716 次 |
| 最近记录: |