How i can use modal dismiss and cancel close

I want to add a product line in Modal and I want to send this product to the main page. I did it with dismiss, but modal also works at cancel yada close. I just want to send data to the main page when I click on the add button in modal and turn off modal.

In your page when you show modal:

let modalObj = this.modalCtrl.create(ModalComponent, modalParams);

modalObj .onDidDismiss((data:any) => {
  //data is the return data from modal
});

modalObj .present();

in your modal:

closeModal() {
    this.viewCtrl.dismiss({
      data: returnedData
    });
  }
1 Like

yes i am doing this but i am trying to turn the function on and off both without canceling it.

I solved this problem with return data checking null or not null