SHARE
TWEET

Untitled

a guest Dec 13th, 2017 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .service('Message', ['$http','messageService','$ionicPlatform','$cordovaSQLite', function($http,messageService,$ionicPlatform,$cordovaSQLite){
  2.     //hier moet ophalen uit DB komen
  3.       function errorHandler(transaction, error) {
  4.        console.log('Message all ERROR: ' + error.message + ' code: ' + error.code);
  5.     }
  6.     var ret = {
  7.         all: function(){
  8.  
  9.             console.log('Message all2:');
  10.  
  11.             db = window.sqlitePlugin.openDatabase({name: "test.db",  location:'default'});
  12.             let messageitems = [];
  13.  
  14.             console.log('Message all: will executesql');
  15.  
  16.             return db.transaction(function(tx) {
  17.                 return tx.executeSql("select * from messages;", [], function(tx, res) {
  18.                   console.log("res.rows.length: " + res.rows.length + " -- should be 1");
  19.                   console.log("res.rows.item(0).cnt: " + res.rows.item(0).cnt + " -- should be 1");
  20.                 });
  21.             } ,function(e) {
  22.                 console.log("ERROR: " + e.message);
  23.             });
  24.  
  25.                                     console.log('Message all: ITEMS LOADED, count = '+messageitems.length);
  26.                                     console.log(messageitems);
  27.                  
  28.          
  29.         },
  30.         add: function(data){
  31.             return $http.post(api_url, data).then(function(resp){
  32.                 return resp.data;
  33.             });
  34.         }
  35.     }
  36.  
  37.     return ret;
  38. }])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top