ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

AlertController or other xxxController bug [ionic2 version: beta.11]

Open betaengine opened this issue 10 years ago • 2 comments

` constructor(private nav: NavController,private alert:AlertController) {

showConfirm() { let confirm = this.alert.create({ title: 'Use this lightsaber?', message: 'Do you agree to use this lightsaber to do good across the intergalactic galaxy?', buttons: [ { text: 'Disagree', handler: () => { console.log('Disagree clicked'); } }, { text: 'Agree', handler: () => { this.nav.push(TabsPage); } } ] }); confirm.present(); }

`

I press 'Agree' go to TabsPage jump to TabsPage,but this confirm box is not hidden.other xxxController may also


betaengine avatar Aug 11 '16 03:08 betaengine

As described in the AlertController docs in your handler you must

  • FIRST dismiss your alert, THEN do your navigation
  • return false

like

handler: () => {
    confirm.dismiss().then(() => {
        this.nav.pop();
    });
    return false;
}

szerner avatar Aug 11 '16 05:08 szerner

Thanks for helping @szerner ! @feifeiwoye the solution above will fix your issue. Thanks for using Ionic!

jgw96 avatar Aug 11 '16 14:08 jgw96