From e522d2e0ffef02cf39453d83e1c7c7d64c417e8c Mon Sep 17 00:00:00 2001 From: Drew Rygh Date: Tue, 8 Dec 2015 15:31:59 -0600 Subject: [PATCH] docs(demos): local storage api demo --- demos/local-storage/app.html | 2 ++ demos/local-storage/index.ts | 38 ++++++++++++++++++++++++++ demos/local-storage/main.html | 50 +++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 demos/local-storage/app.html create mode 100644 demos/local-storage/index.ts create mode 100644 demos/local-storage/main.html diff --git a/demos/local-storage/app.html b/demos/local-storage/app.html new file mode 100644 index 0000000000..5f6bb33d68 --- /dev/null +++ b/demos/local-storage/app.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/demos/local-storage/index.ts b/demos/local-storage/index.ts new file mode 100644 index 0000000000..958291f4dd --- /dev/null +++ b/demos/local-storage/index.ts @@ -0,0 +1,38 @@ +import {App, Page, IonicApp, Config, Platform} from 'ionic/ionic'; +import {Storage, LocalStorage} from 'ionic/ionic'; + + +@App({ + templateUrl: 'app.html' +}) +class ApiDemoApp { + + constructor() { + this.rootPage = InitialPage; + } +} + +@Page({ + templateUrl: 'main.html' +}) +export class InitialPage { + constructor() { + this.local = new Storage(LocalStorage); + this.myItem = {}; + this.delKey = ''; + this.localStorageDemo = '{}'; + window.localStorage.clear(); + } + + set() { + this.local.set(this.myItem.key, this.myItem.value ); + this.localStorageDemo = JSON.stringify(window.localStorage, null, 2); + this.myItem = {}; + } + + remove() { + this.local.remove(this.delKey); + this.localStorageDemo = JSON.stringify(window.localStorage, null, 2); + this.delKey = ''; + } +} diff --git a/demos/local-storage/main.html b/demos/local-storage/main.html new file mode 100644 index 0000000000..6f77643bc0 --- /dev/null +++ b/demos/local-storage/main.html @@ -0,0 +1,50 @@ + + Local Storage + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Local Storage: + + {{localStorageDemo}} + + +