이온 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);
}
예 2 : 다른 페이지에서 다른 페이지
에 액세스 연락처 내가 접촉을 통해 반복하고 라디오 경고 상자의 목록에 표시 . 다시 연락처가 성공적으로 표시되지만 연락처 추가 페이지에 연락처를 추가하면 새 연락처가 라디오 경고 상자 목록에 나타나지 않습니다.
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