mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
43 lines
886 B
TypeScript
43 lines
886 B
TypeScript
import {Component, Control, ControlGroup} from 'angular2/angular2';
|
|
|
|
import {App, Storage, LocalStorage, SqlStorage} from 'ionic/ionic';
|
|
|
|
@App({
|
|
templateUrl: 'main.html'
|
|
})
|
|
class IonicApp {
|
|
constructor() {
|
|
this.local = new Storage(LocalStorage);
|
|
this.sql = new Storage(SqlStorage);
|
|
}
|
|
getLocal() {
|
|
this.local.get('name').then(value => {
|
|
alert('Your name is: ' + value);
|
|
});
|
|
}
|
|
setLocal() {
|
|
let name = prompt('Your name?');
|
|
|
|
this.local.set('name', name);
|
|
}
|
|
removeLocal() {
|
|
this.local.remove('name');
|
|
}
|
|
|
|
getSql() {
|
|
this.sql.get('name').then(value => {
|
|
alert('Your name is: ' + value);
|
|
}, (errResult) => {
|
|
console.error('Unable to get item from SQL db:', errResult);
|
|
});
|
|
}
|
|
setSql() {
|
|
let name = prompt('Your name?');
|
|
|
|
this.sql.set('name', name);
|
|
}
|
|
removeSql() {
|
|
this.sql.remove('name');
|
|
}
|
|
}
|