Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229528

Store objects in LocalStorage

$
0
0

Hi

localStorage.setItem("lastname", "Smith")

http://www.w3schools.com/html/html5_webstorage.asp

Or better: use the Storage object and Sqlstorage as found in the api of Ionic2

import { Storage, SqlStorage } from 'ionic-framework/ionic';

this.storage = new Storage(SqlStorage);

this.storage.get('questionnaires').then((data) => {
if (data != null) this.questionnaires = JSON.parse(data);
	else this.loadDefaultQuestions();

And to store Objects, use JSON.stringify(myObject) to store and JSON.parse(...) to turn back

Regards

Tom


Viewing all articles
Browse latest Browse all 229528

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>