Skip to content

Instantly share code, notes, and snippets.

@ovpv
Created January 1, 2020 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ovpv/668d70f6564f4be508e481437420e347 to your computer and use it in GitHub Desktop.
Save ovpv/668d70f6564f4be508e481437420e347 to your computer and use it in GitHub Desktop.
Using setMessage method in alert component
import { Component } from '@angular/core';
import { AlertController } from '@ionic/angular';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss']
})
export class HomePage {
alert: any;
constructor(public alertController: AlertController) {}
async presentAlert() {
this.alert = await this.alertController.create({
header: 'Alert',
subHeader: 'Subtitle',
message: 'This is an alert message.',
buttons: ['OK']
});
await this.alert.present();
this.updateAlertMessage();
}
updateAlertMessage() {
setTimeout(() => {
// ionic 3
this.alert.setMessage('This the updated Alert Message');
// ionic 4
this.alert.message = 'This the updated Alert Message';
}, 3000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment