我一直使用离子2存在的问题之一是存储服务。我已成功设置和检索存储的数据。但是,当我存储的东西,除非我刷新页面/应用程序,其他页面无法访问。与离子2存储服务同步访问存储
例一:编辑联系人
我推到一个编辑联系人页面,进行更改,然后saveEdits。 saveEdits成功更改为正确的联系人,但无法更新联系人列表直到应用程序刷新。
HTML:
<button (click)="saveEdits(newName, newPostCode)"ion-button round>Save Edits</button>
打字稿:
saveEdits(newName, newPostCode){
console.log("saveid"+this.id);
this.name = newName; //saves property
this.postcode = newPostCode; //saves property
this.items[this.id] = {"id": this.id, "Name": newName, "PostCode": newPostCode};
this.storage.set('myStore',this.items);
//this.navCtrl.pop(ContactPage);
}
例二:浏览其他网页
上的联系人另一页我通过接触迭代,并在无线电警告框列表中显示。同样,联系人显示成功,但是当我在添加联系人页面上添加联系人时,新联系人不会出现在收音机警告框列表中。
addDests(){
console.log('adddests');
{
let alert = this.alertCtrl.create();
alert.setTitle('Choose Friend');
for(let i = 0; i<this.items.length; i++){
console.log('hello');
alert.addInput({
type: 'radio',
label: this.items[i].Name,
value: this.items[i].PostCode,
checked: false
});
}
alert.addButton('Cancel');
alert.addButton({
text: 'OK',
handler: data => {
console.log(data);
}
});
alert.present();
}
}
你能查看我对其他回复的评论吗? – Dansmith12