在你的HTML中:
在你的add.ts文件中:
export class AddPage { form : any; //Declare the form object to be bound to your html constructor(public viewCtrl: ViewController, public navCtrl: NavController, public navParams: NavParams) {} CloseModal() { this.viewCtrl.dismiss(this.form); //Send back the form object when closeModal is called } }
在你的家里:
addWeather() { let addWeatherModal = this.modalCtrl.create(AddPage); addWeatherModal.present(); addWeatherModal.onDidDismiss(data=>{ //This is a listener which wil get the data passed from modal when the modal's view controller is dismissed console.log("Data =>", data) //This will log the form entered by user in add modal. }) }