0
我有一個angular2服務,它使用LocalStorage來存儲我的應用程序的相關數據。如何將HTML本地存儲服務轉換爲Angular 2中的indexedDB服務?
import { Injectable } from '@angular/core';
@Injectable()
export class LocalStorageService {
get(item) {
return JSON.parse(localStorage.getItem(item));
}
set(target, item) {
localStorage.setItem(target, JSON.stringify(item));
}
remove(item) {
localStorage.removeItem(item);
}
}
由於數據增長的應用程序(超過15 MB現在),我決定用IndexedDB v1.0而不是localStorage的。有人可以幫助我重新定義我的get(),set()和remove()函數,記住我希望方法是同步的(特別是get()和remove()方法)?