Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

292
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda