私のアプリケーション内でIonic Storageをどのように使用できますか?私は次のことを試しましたが、私が読むことを試みるとき、私はいつも値として[object Object]
を返します。 1つのクラスにget/setメソッドがある場合に機能しますが、私はプロジェクトを構造化し、ストレージ部分を外部に委譲したいと考えています。Ionic Storageは未定義の値を提供します
@Component({
selector: 'page-login',
templateUrl: 'login.html'
})
export class LoginPage {
constructor(public testData: TestData) {}
onLogin(form) {
if (form.valid) {
this.testData.setTestParam("abc");
console.log("Stored: " + this.testData.getTestParam()) ;
// delivers => Stored: [object Object]
}
}
TESTDATAクラス
@Injectable()
export class TestData {
constructor(public storage : Storage) {}
setTestParam(testparam)
{
this.storage.set('test_param', testparam);
}
getTestParam(){
return this.storage.get('test_param').then((value) => {
return value;
});
}
}
あなたのデバッグコンソールにアクセスし、中にあなたの[アプリケーション]タブに、データがWebSQLの下に保存されているか、どちらかのドライバは、私がしなければならない – misha130