我正在动态生成离子警报,如以下代码所示:
displayMessage(msg: string, title: string, displayButtonText: Array < any >=
['OK']) {
let displayButton: Array < any >= [];
for (var i = 0; i < displayButtonText.length; i++) {
var buttonText=displayButtonText[i];
displayButton.push({
text: displayButtonText[i],
handler: () => {
this.setButtonValue(Array.from(displayButtonText)[i]);
}
})
}
let popUp = this.alertCtrl.create({
title: title,
subTitle: msg,
buttons: displayButton
});
popUp.present();
}
我正在尝试传递2个值“确定”和“取消”,但我无法将它们传递给handler()中的this.setButtonValue()。