async presentAlertRadio(heading:string){
const alert = await this.alertCtrl.create({
header: heading,
inputs :[
{
name : 'Radio 1',
type: 'radio',
label: 'Radio 1',
value: 'value1',
checked: true
},
{
name: 'radio2',
type: 'radio',
label: 'Radio 2',
value: 'value2'
},
],
buttons: [
{
text: 'Cancel',
role: 'cancel',
cssClass: 'secondary',
handler: () => {
console.log('Confirm Cancel');
}
}, {
text: 'Ok',
handler: (data) => {
console.log('Confirm Ok', data);
}
}
]
});
await alert.present();
}
我想将警报控制器中所选无线电的值分配给一个变量,我该如何访问它。
离子4的新手,所以真的不知道
我想分配我的var x = selectedRadio
答案 0 :(得分:1)
text: 'Ok',
handler: (data) => {
console.log('Confirm Ok', data); //handle data here eg.
this.x = data.value1; // this assigns your veritable 'x' to the value
// of Radio 1
}
评论,如果需要澄清
答案 1 :(得分:0)
text: 'Ok',
handler: (data) => {
console.log('Confirm Ok', data);
this.x = data;
}