How to do when clicking on the ok of the alert, only then go to another page?

2
Well, guys, I'm learning ionic now in college, and I wonder if it's possible, in an alert, to make it only after the user clicks 'ok', in my case 'change', it goes 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();
}
    
asked by anonymous 11.11.2017 / 22:56

1 answer

1

It worked for min 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();
}
    
12.11.2017 / 14:41