0
私は以下のような私のクラスからモーダルにデータを渡しています。ChangeCheck()
をモーダルビュー内でトリガーすると、MyMap
クラスに戻るときにcheckin
は変更されません。私はそれが私のモーダルの価値だと思う。ページとモーダルの間のイオン2依存性注入
@Component({
selector: 'page-my-map',
templateUrl: 'my-map.html',
providers:[CommonVariables]
})
export class MyMap {
checkin:boolean=false;
constructor(public commonvar:CommonVariables,public modalCtrl:
ModalController,
public nav:NavController,public alertCtrl:AlertController) {
}
public openBasicModal() {//this functions is triggered once I click the button to open my Modal
let myModal = this.modalCtrl.create(ModalContentPage,{'myParam':this.checkin});
myModal.present();
}
}
@Component({//this is my modal template
templateUrl:'my-modal.html',
})
export class ModalContentPage {//my modal class
checkin:boolean;
constructor(public alertCtrl:AlertController,
public viewCtrl: ViewController,
params: NavParams,
public commonvar:CommonVariables
) {
this.checkin = params.get('myParam');//I am getting this value from MyClass .
}
ChangeCheck () {//I trigger this function.but when I close the my modal, it doesn't change the checkin which inside `MyClass`.
this.checkin = !this.checkin;
}
dismiss() {
this.viewCtrl.dismiss();
}
}
申し訳ありません、あなたのModalContentPageクラスでこれを追加するには、ModalControllerクラスに
これを追加それを修正してください。 –
変更しましたが、まだ同じです。 –
ありがとうございます! :) @LeRoy –