我想恢复所有包含变量this.userConfiguration
的数据,该变量与navparams一起从另一页推入。我尝试使用副本,但是当我再次更改数据时,不再重置数据,因为很明显,副本将使用输入的值。
HTML文件 :(数据与this.userConfiguration variable
连接。)
<ion-content padding>
<ion-list>
<button ion-item (click)="changeValue()">
<ion-label text-left>Valuta</ion-label>
<ion-label text-right>{{userConfiguration.DEFAULTCURRENCY.ValueOfString}}</ion-label>
</button>
<button ion-item (click)="changeCountryRegion()">
<ion-label text-left>Nation/Country</ion-label>
<ion-label text-right>{{userConfiguration.ECM_ShopCountry.ValueOfString}}</ion-label>
</button>
</ion-content>
TS文件
ionViewCanLeave() {
if (this.changed == true) {
return new Promise((resolve, reject) => {
let confirm = this.alertCtrl.create({
title: 'you have made changes',
message: 'do you want to exit without saving changes??',
buttons: [{
text: 'Yes',
handler: () => {
this.save();
resolve();
},
}, {
text: 'No',
handler: () => {
this.userConfiguration = this.userConfigurationCopy
resolve();
}
}]
});
confirm.present();
});
}
}