Created
January 1, 2020 06:52
-
-
Save ovpv/668d70f6564f4be508e481437420e347 to your computer and use it in GitHub Desktop.
Using setMessage method in alert component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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