本文整理匯總了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);
}
}
};