How to do by clicking the Alert ok, just then go to another page?

Asked

Viewed 400 times

2

Good guys, I’m learning Ionic now in college, and would like to know if it is possible, in an Alert, to make it only after the user click 'ok', in my case 'change', it go to a certain page? Thank you for your attention.

Code:

presentConfirm() {
let alert = this.alertCtrl.create({
  title: 'Alteração',
  message: 'Você realmente deseja alterar?',
  buttons: [
    {
      text: 'Não',
      role: 'cancel',
      handler: () => {
        console.log('Clicou no Cancelar');
      }
    },
    {
      text: 'Sim',
      handler: () => {
        console.log('Clicou no Alterar');
      }
    }
  ]
});
alert.present();
}

1 answer

1


It worked for me this way

presentConfirm() {
let alert = this.alertCtrl.create({
  title: 'Alteração',
  message: 'Você realmente deseja alterar?',
  buttons: [
    {
      text: 'Não',
      role: 'cancel',
      handler: () => {
        console.log('Clicou no Cancelar');

      }
    },
    {
      text: 'Sim',
      handler: () => {
        console.log('Clicou no Alterar');
        this.navCtrl.push(NovaPage);
      }
    }
  ]
});
alert.present();
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.