本文整理汇总了TypeScript中angular2-local-storage/local_storage.LocalStorage类的典型用法代码示例。如果您正苦于以下问题:TypeScript LocalStorage类的具体用法?TypeScript LocalStorage怎么用?TypeScript LocalStorage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LocalStorage类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(
public _demoService: DemoService,
private ls:LocalStorage) {
if(Object.getOwnPropertyNames(this.ls.getObject('main')).length === 0){
this.ls.setObject('settings', []);
}
}
示例2: remove
remove(key) {
this.cache[key] = null;
delete this.cache[key];
this._cookieService.remove(key);
this._localStorage.remove(key);
}
示例3: nuke
nuke() {
for (let cookie in this.cacheKeys) {
let key = this.camelize(cookie);
this._localStorage.remove(key);
}
this._cookieService.removeAll();
this.cache = {};
}
示例4: put
put(key, value) {
if (key !== this.cacheKeys.Card) {
try {
this._cookieService.put(key, value);
this._localStorage.set(key, value);
this.cache[key] = value;
} catch (e) {
console.error('cache error!', e);
}
}
};