I’m in the process of learning new skills with Ionic 4 and Angular. I’m following a course on UDemy. In my first attempt to complete an assignment I could not get a simple example with AlertController to work. The code from UDemy looks like this (note: It’s a course from 2015 using Ionic 2):
showAlert()
{
let alert = this.alertController.create({
message: “Joepie”,
subHeader: “Test”
});
alert.present();
}
I’m using Visual Studio Code and it immediately gives me an error on ‘present’. After struggling a while with the code I came up with the code below. It is working (with Ionic 4) but I’m a bit uncertain about it. Is this how it is supposed to work?
showAlert()
{
let alert = this.alertController.create({
message: “Joepie”,
subHeader: “Test”
});
alert.then(x => x.present());
}