· 7 years ago · Feb 09, 2019, 12:32 PM
1var customerStr = JSON.stringify($scope.indexData);
2var db = openDatabase('customerDB', '1.0', 'customer DB', 2 * 1024 * 1024);
3
4 db.transaction(function (tx) {
5 tx.executeSql('CREATE TABLE IF NOT EXISTS CUSTOMER (id unique, userid, customerdata VARCHAR)');
6 tx.executeSql('INSERT INTO CUSTOMER (id, userid, customerdata) VALUES (1, 2, customerStr)');
7 console.log('<p>Log message created and row inserted.</p>');
8
9 });
10
11'CREATE TABLE IF NOT EXISTS CUSTOMER (id unique, userid, customerdata VARCHAR)'
12
13if(typeof(Storage) !== "undefined") {
14 // Code for localStorage/sessionStorage.
15} else {
16 // Sorry! No Web Storage support..
17}
18
19// Store
20localStorage.setItem("lastname", "Smith");
21// Retrieve
22document.getElementById("result").innerHTML = localStorage.getItem("lastname");