Home:ALL Converter>How to return a promise with alertcontroller in ionic 4?

How to return a promise with alertcontroller in ionic 4?

Ask Time:2019-06-18T03:32:14         Author:Kevin

Json Formatter

I am trying to convert this ionic 3 code into ionic 4 but I don't know how the promise works on ionic 4. I tried looking into the documentations and I can't find any solutions to promises

async generateAlert(header, message, ok, notOk): Promise<boolean> {
    return new Promise((resolve, reject) => {
        let alert = await this.alertController.create({
            header: header,
            message: message,
            buttons: [
                {
                    text: notOk,
                    handler: _=> reject(false)
                },
                {
                    text: ok,
                    handler: _=> resolve(true)
                }
            ]
        })
        await alert.present();
    });
}

Author:Kevin,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/56637790/how-to-return-a-promise-with-alertcontroller-in-ionic-4
yy