【发布时间】:2018-08-20 21:46:52
【问题描述】:
我正在制作 ionic 3 应用程序。注册页面中有验证 otp 功能。当用户单击注册按钮时,将打开带有取消、验证和重新发送按钮的 otp 输入的警报。当用户点击重新发送按钮时我想要做的是同样的警报应该打开。我通过在重新发送按钮处理程序中复制整个警报代码来做到这一点。但它只是第一次开放。当用户单击重新发送按钮时,我想无限地重新打开此警报。
以下是我的警报代码
{
let alert = this.alertCtrl.create({
title: 'OTP Sent. Verify OTP',
inputs: [{
name: 'otp',
placeholder: 'OTP',
value: this.otp
}, ],
buttons: [{
text: 'Cancel',
role: 'cancel',
handler: data => {
console.log('Cancel clicked');
}
},
{
text: 'Verify',
handler: data => {
console.log(data.otp);
if (this.responseData.data.otp_sent == data.otp) {
console.log("verfiied");
} else {
// invalid login
return false;
}
}
},
{
text: 'Resend',
handler: data => {
this.authService.postData('mobile=' + this.responseData.data.mobile, 'user/resend').then((result) => {
// console.log(this.otpResend);
let alert = this.alertCtrl.create({
title: 'OTP Sent. Verify OTP',
inputs: [{
name: 'otp',
placeholder: 'OTP',
value: this.otp
}, ],
buttons: [{
text: 'Cancel',
role: 'cancel',
handler: data => {
console.log('Cancel clicked');
}
},
{
text: 'Verify',
handler: data => {
console.log(data.otp);
if (this.responseData.data.otp_sent == data.otp) {
console.log("verfiied");
} else {
// invalid login
return false;
}
}
},
{
text: 'Resend',
handler: data => {
this.authService.postData('mobile=' + this.responseData.data.mobile, 'user/resend').then((result) => {
// console.log(this.otpResend);
});
}
}
]
});
alert.present();
});
}
}
]
});
alert.present();
}
【问题讨论】:
-
它只调用一次,所以需要递归调用.....
标签: javascript angularjs ionic-framework ionic3