本文整理汇总了TypeScript中ionic-angular.Storage类的典型用法代码示例。如果您正苦于以下问题:TypeScript Storage类的具体用法?TypeScript Storage怎么用?TypeScript Storage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Storage类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(public nav: NavController,
public view: ViewController,
public translate: TranslateService) {
this.local = new Storage(LocalStorage);
var userLang = navigator.language.split('-')[0];
userLang = /(de|en|hr)/gi.test(userLang) ? userLang : 'en';
this.local.get('language')
.then((l) => {
if (l) {
this.language = l;
} else {
this.language = userLang;
}
});
}
示例2: constructor
constructor(private navCtrl: NavController, private navParams: NavParams, private loadingCtrl: LoadingController, private modalCtrl: ModalController) {
this.global = this.navParams.get('global');
this.sku = this.navParams.get('sku');
this.name = this.navParams.get('name');
this.slideOptions = {
autoplay: 2000,
loop: true,
pager: true
};
this.global.subData = {};
this.global.isLoaded = false;
let loader = this.loadingCtrl.create({
content: this.global.message.pleaseWait+"...",
});
loader.present();
var timer = setInterval(() => {
if(this.global.isLoaded) {
clearInterval(timer);
loader.dismiss();
}
}, 500);
let storage = new Storage(LocalStorage);
storage.get('token').then((token) => {
this.global.socket.emit('api', {
token: token,
module: 'product',
action: 'info',
sku: this.sku
});
});
}
示例3: logout
logout() {
localStorage.removeItem('appKey');
localStorage.removeItem('appSecret');
localStorage.removeItem('consumerKey');
localStorage.removeItem('widgets');
localStorage.removeItem('credentials');
localStorage.removeItem('connected');
this.ovhRequest.setConfiguration({});
return this.nav.setRoot(LoginPage);
}
示例4: function
global.socket.on('access', function (data) {
if (data.success) {
storage.set('token', data.token);
global.socket.emit('api', {
token: data.token,
module: 'system',
action: 'language',
system: 'mobile',
langCode: global.langCode
});
global.socket.emit('api', {
token: data.token,
module: 'system',
action: 'screen'
});
//-- ข้อมูลจำนวนสินค้าในรถเข็น --//
global.socket.emit('api', {
token: data.token,
module: 'cart',
action: 'summary'
});
}
else {
storage.remove('token');
if (retryCount < 3) {
global.socket.emit('access', { token: '' });
retryCount++;
}
else {
alert(data.error + "\n" + data.errorMessage);
}
}
});
示例5: getTasks
getTasks(){
let sql = `SELECT * from tasks`;
return this.tasks.query( sql )
.then(response =>{
let data = [];
for (let index = 0; index < response.res.rows.length; index++) {
data.push({
id: response.res.rows[index].id,
title: response.res.rows[index].title,
completed: response.res.rows[index].completed == "true" ? true : false
});
}
return Promise.resolve(data);
});
}
示例6: save
save(data): void {
let saveData = [];
//Remove Observables
data.forEach((checklist) => {
saveData.push({
title: checklist.title,
items: checklist.items,
createdOn: checklist.createdOn
});
});
let newData = JSON.stringify(saveData);
this.storage.set('checklist', newData);
}
示例7: Promise
return new Promise((resolve, reject) => {
//this.platform.ready().then(() => {
/*this.storage.query('CREATE TABLE IF NOT EXISTS data (key TEXT PRIMARY KEY, value TEXT)').then((data) => {
this.storage.query("INSERT OR IGNORE INTO data (key, value) VALUES " +
"('familias', '')," +
"('likes', '')," +
"('entity', '')," +
"('user', '')," +
"('tiposElementos', '')," +
"('tiposIncidencias', '')," +
"('estados', '')," +
"('responsables', '')," +
"('firstRun', '')," +
"('language', '');").then((data) => {
resolve(data);
}, (error) => {
//reject("ERROR -> " + error);
console.log(error);
});
}, (error) => {
//reject("ERROR -> " + error);
console.log(error);
});*/
this.storage.query("INSERT OR IGNORE INTO kv (key, value) VALUES " +
"('familias', '')," +
"('likes', '')," +
"('entity', '')," +
"('user', '')," +
"('tiposElementos', '')," +
"('tiposIncidencias', '')," +
"('estados', '')," +
"('responsables', '')," +
"('firstRun', '')," +
"('language', '');").then((data) => {
resolve(data);
}, (error) => {
//reject("ERROR -> " + error);
console.log(error);
});
});
示例8:
storage.get('page').then((page) => {
if (page == 'signOut' || page == 'signIn') {
storage.set('page', 'shopping');
global.socket.emit('api', {
token: data.token,
module: 'system',
action: 'screen'
});
global.socket.emit('api', {
token: data.token,
module: 'member',
action: 'profile'
});
}
});
示例9: KEY
');').then((data) => {
this.storage.query('CREATE TABLE IF NOT EXISTS Base_atribute (' +
'_id INTEGER PRIMARY KEY AUTOINCREMENT,' +
'System_id INTEGER,' +
'name TEXT NULL,' +
'FOREIGN KEY(System_id) REFERENCES System(_id)' +
');').then((data) => {
this.storage.query('CREATE TABLE IF NOT EXISTS Secundary_atribute (idSecundary_atribute INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT);')
.then((data) => {
this.storage.query('CREATE TABLE IF NOT EXISTS Characters_has_Skill (' +
'Characters_idCharacters INTEGER,' +
'Skill_idSkill INTEGER,' +
'level INTEGER UNSIGNED NULL,' +
'FOREIGN KEY(Characters_idCharacters) REFERENCES Characters(_id),' +
'FOREIGN KEY(Skill_idSkill) REFERENCES Skill(_id)' +
');').then((data) => {
this.storage.query('CREATE TABLE IF NOT EXISTS Characters_has_Secundary_atribute (' +
'Characters_idCharacters INTEGER,' +
'Secundary_atribute_idSecundary_atribute INTEGER,' +
'value INTEGER,' +
'FOREIGN KEY(Characters_idCharacters) REFERENCES Characters(_id),' +
'FOREIGN KEY(Secundary_atribute_idSecundary_atribute) REFERENCES Secundary_atribute(_id)' +
');').then((data) => {
this.storage.query('CREATE TABLE IF NOT EXISTS Characters_has_Base_atribute (' +
'Characters_idCharacters INTEGER,' +
'Base_atribute_idBase_atribute INTEGER,' +
'value INTEGER,' +
'FOREIGN KEY(Characters_idCharacters) REFERENCES Characters(_id),' +
'FOREIGN KEY(Base_atribute_idBase_atribute) REFERENCES Base_atribute(_id)' +
');').then((data) => {
console.log("DB OK");
}, (error) => {
console.log("Characters_has_Base_atribute ERROR -> " + JSON.stringify(error.err), error);
});
}, (error) => {
console.log("Characters_has_Secundary_atribute ERROR -> " + JSON.stringify(error.err), error);
});
}, (error) => {
console.log("Characters_has_Skill ERROR -> " + JSON.stringify(error.err), error);
});
}, (error) => {
console.log("Secundary_atribute ERROR -> " + JSON.stringify(error.err), error);
});
}, (error) => {
console.log("Base_atribute ERROR -> " + JSON.stringify(error.err), error);
});
}, (error) => {