1) The first option, just using a class to warn, and a CSS style rule for each button
showAlert(title, message, yesHandler, noHandler, caller) {
let alert = this.alertCtrl.create({
title: title || "Please Confirm",
message: message,
cssClass:'buttonCss',
buttons: [
{
text: 'Exit',
handler: () => yesHandler(caller)
},
{
text: 'Cancel',
role: 'cancel',
handler: () => noHandler(caller)
}
]
});
alert.present();
}
And then:
.buttonCss {
button.alert-button:nth-child(1){
color: red;
}
button.alert-button:nth-child(2){
color: green;
}
}
Thus, the first button ( nth-child(1)
) will be red
, and the second button ( nth-child(2)
) will be green
.
2) , , cssClass
,
showAlert(title, message, yesHandler, noHandler, caller) {
let alert = this.alertCtrl.create({
title: title || "Please Confirm",
message: message,
cssClass:'buttonCss',
buttons: [
{
text: 'Exit',
cssClass: 'exit-button',
handler: () => yesHandler(caller)
},
{
text: 'Cancel',
role: 'cancel',
cssClass: 'cancel-button',
handler: () => noHandler(caller)
}
]
});
alert.present();
}
:
.buttonCss {
button.alert-button.exit-button{
color: red;
}
button.alert-button.cancel-button{
color: green;
}
}