保存,检索和数据上传到远程服务器---(AngularJs /离子) [英] Save ,retrieve and upload data to a remote server---(AngularJs / Ionic)

查看:135
本文介绍了保存,检索和数据上传到远程服务器---(AngularJs /离子)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您所有的教程,是极大的帮助,帮助我们在很多方面都非常感谢。
请,我有双手要解决的问题,虽然我是在角/离子新手。

Many thanks for all your tutorials that have greatly helped and helping us in so many ways. Please, i have problem at hands to solve though i'm a newbie in angular/ionic.

1)我有一个包含多个输入收集如姓名,性别,出生日期,职业等。在表单我有分别的图像标签和按钮来显示和捕捉图像的底部个人信息的形式。我能捕捉并显示拍摄的图像。

1) I have a form that contains several inputs to collect personal info like names, gender, DOB, Occupation etc. At the bottom of the form i have image tag and a button to display and capture image respectively. I was able to capture and displayed the captured image.

问题描述:
1)我想保存所有的个人信息,包括在本地存储所拍摄的图像。为什么?因为糟糕的网络。

PROBLEM STATEMENT: 1) I would like to save all the personal info including the captured image on a local storage. Why? because of bad network.

2)我想检索保存的信息和图像,并上传到远程服务器。

2) I would like to retrieve the saved info and image and upload to a remote server.

请,我会如此感激,如果你愿意,你可以说明这一个简单而简短的教程。
再次感谢。

Please, i would be so grateful if you can illustrate this with a simple and short tutorial as you wish. Thanks once again.

推荐答案

您可能要考虑使用SQLite的科尔多瓦存储。 链接

You may want to consider using Cordova sqlite storage. Link

要做到这一点,

通过安装插件到您的离子项目文件夹:

Install the plugin into your ionic project folder via:

cordova plugin add https://github.com/brodysoft/Cordova-SQLitePlugin.git

获取NG-cordova.min.js并添加到UR的javascript目录,添加此以下code线到您的index.html。

Get ng-cordova.min.js and add into ur javascript directory, add this following line of code into your index.html.

<script src="<your folder>/ng-cordova.min.js"></script>

注入通过您的角度模块(app.js):

Inject into your angular module(app.js) via:

angular.module('starter', ['ionic', 'ngCordova'])

通过创建数据库:

Create a database via :

.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)");

这是插入示例:

 $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);
        });
    }

您的图像文件,然后能够存储为一个blob和乐趣! (:

Your image file is then able to store as a blob and have fun ! (:

这篇关于保存,检索和数据上传到远程服务器---(AngularJs /离子)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆