显示离子弹出窗口后退出应用程序

时间:2017-11-19 10:28:05

标签: ionic-framework

我的应用程序中有这个代码:

$ionicPopup.alert({
    title: $scope.header1,
    template: 'The was a problem connecting to the server.  Please check your internet connection and try again.'
});
ionic.Platform.exitApp() 

我注意到的是,在Android中,应用程序快速退出而不显示弹出消息。我想做的是执行

ionic.Platform.exitApp() 

用户按下'确定&#39>弹出窗口中的按钮。那里有像" onleave"离子弹出事件?

1 个答案:

答案 0 :(得分:0)

最好的方法可能是定义自己的“好”。按钮而不是利用默认关闭按钮 - 这样您就可以在用户点击/点击按钮时调用import { AlertController } from 'ionic-angular'; constructor(private alertCtrl: AlertController) { } presentAlert() { let alert = this.alertCtrl.create({ title: YourCustomHeader, //subTitle: 'optional text', message: 'The was a problem connecting to the server. Please check your internet connection and try again.', buttons: [ { text: 'OK', handler: () => { ionic.Platform.exitApp(); } } ] }); alert.present(); }

示例:

self.result

参考:https://ionicframework.com/docs/api/components/alert/AlertController/#usage