Ionic 4 - AlertController: Property 'present' does not exist - Angular?
The documentation you are using refers to ionic 3
As you are using Ionic 4, you need to refer to the current Ionic 4 docs and this.
this.alertController.create({...})
returns promise of the object as the error specifies.
Your code needs to be:
async presentAlert() {
const alert = await this.alertCtrl.create({
message: 'Low battery',
subHeader: '10% of battery remaining',
buttons: ['Dismiss']
});
await alert.present();
}
Since create method of alert controller return promise that's why you can not use present method directly. What you need to do is "use then" and call present method like below-
presentAlert() {
const alert = this.alertCtrl.create({
message: 'Low battery',
subHeader: '10% of battery remaining',
buttons: ['Dismiss']}).then(alert=> alert.present());
}
Hope it will helpful :).