Ionic 4 - How to dIsplay error result in alert

Moderator: Support

Peter Westcott
Posts: 1
Joined: Wed Sep 30, 2015 8:37 pm

Ionic 4 - How to dIsplay error result in alert

Post by Peter Westcott »

Hello

How can I use the result of the error on the message text of the alert?

screenshot-appery.io-2020.09.11-23_46_47.png
screenshot-appery.io-2020.09.11-23_46_47.png (68.66 KiB) Viewed 537 times
Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

Re: Ionic 4 - How to dIsplay error result in alert

Post by Serhii Kulibaba »

Hello,

Please use a custom TypeScript there. Only there the error variable is available, so you can use it to display its value in the alert, e.g.:

Code: Select all

await (async () => {
            let options = {
                'header': 'Error',
                'message': JSON.stringify(err),
                'subHeader': '',
                'buttons': [{
                    'text': 'OK',
                }]
            }
            let controller = this.Apperyio.getController('AlertController');
            const alert = await controller.create(options);
            return await alert.present();
        })();
Post Reply