Save ,retrieve and upload data to a remote server---(AngularJs / Ionic)

前端 未结 1 735
我在风中等你
我在风中等你 2020-12-20 00:36

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条回答
  •  温柔的废话
    2020-12-20 01:07

    You may want to consider using Cordova sqlite storage. Link

    To do it,

    Install the plugin into your ionic project folder via:

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

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

    
    

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

    An Insert Example:

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

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

    0 讨论(0)
提交回复
热议问题