Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

285
Views
Ionic 2 onDidDismiss() saves even when cancel() button is pressed

I'm having an issue with my Ionic 2 app. I've so far built a list page of items, and each item there navigating to a detail page. At the detail page, you can edit and choose to save or cancel any changes. Save is working great.

The issue is onDidDismiss() function saving the data even when the close function doesn't/shouldn't pass the data back to the detail page. Here's the relevant code.

DETAILS.ts

openModal() {
  let data = this.user;
  let editDetailsModal = this.modalCtrl.create(EditDetailsModal, data);

  editDetailsModal.onDidDismiss((data) => {
    if (data) {
      // this.saveItem(data);
      console.log("Data =>", data)
    }
    //console.log("Data =>", data)
  });
  editDetailsModal.present();

}

saveItem(data) {
  this.user.push(data);
}

EDITDETAILSMODAL.ts

saveModal() {
  let data = this.user;
  this.viewCtrl.dismiss(data);
  //console.log(this.user)
}

close() {
  this.viewCtrl.dismiss();
}

EditDetailsModal page has a form to edit the data passed to it. I'm sure I'm missing something simple. Even when calling an external save function, it just made a mess of the app. Happy to do a plunkr if this isn't enough information.

Ionic Info

Cordova CLI: 6.4.0 
Ionic Framework Version: 3.0.1
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.3.0
ios-deploy version: 1.9.1 
ios-sim version: 5.0.13 
OS: macOS Sierra
Node Version: v6.9.5
Xcode version: Xcode 8.3.1 Build version 8E1000a
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!