angular - 如何将计数器值传递给 AlertController 的标头
问题描述
我正在尝试将值实际传递给警报控制器的标头。出现警报,但不幸的是标题没有显示当前的 this.counter 值。
所以这是我的一段代码。请注意,函数 idleAlert() 是从构造函数启动的。
private counter: number;
startCountdown(seconds) {
let counter = seconds;
const interval = setInterval(() => {
this.counter = this.counter;
counter--;
if (counter < 0) {
clearInterval(interval);
console.log('Ding!');
}
}, 1000);
}
async idleAlert() {
this.startCountdown(100);
this.alertIdle = await this.alertController.create({
header: 'Current counter value is: ' + this.counter,
cssClass: 'customAlert',
backdropDismiss: false,
buttons: [
{
text: 'Logout',
role: 'cancel',
cssClass: 'alertBtnGrey',
handler: (data) => {
this.stopWatching();
this.authService.logout();
}
}, {
text: 'Contrinue',
cssClass: 'alertBtnSuccess',
handler: () => {
this.restartTimer();
}
}
]
});
await this.alertIdle.present();
}
解决方案
推荐阅读
- php - 如何根据解码数组替换字符串中某个字符后的两个字符?
- c - 使用 C11 原子操作的可移植字对齐
- python - scoring problem with Two player dice game
- javascript - Building To-do list website that works with append, having trouble deleting notes in javascript
- x11 - What is a SaveSet in XWindows
- python - Path configuration for sqlite3 in python3.6
- windows - 在 Windows 主机文件上映射 Docker 实例(Docker 位于 Vagrant VM 中)
- python - Error give role when a user add reaction Discord.py
- sql - Stored procedure is not returning expected custom exception message
- sql - Very large number of SQL UNION SELECT statements exceeds max_stack_depth