angular 4 中 ReCaptchaModule 的过期回调

Expire callback in ReCaptchaModule in angular 4

我在 jQuery 中使用了 reCaptcha 有办法在验证码 checkedcaptcha 过期后立即获取事件。现在我正在使用 Angular 4 并使用 import { ReCaptchaModule } from 'angular2-recaptcha'; 。检查验证码时也有获取事件的方法。

handleCorrectCaptcha(evt) {
if (evt != null || typeof evt !== typeof undefined) {
  this.captchaChecked = true;
  this.captchCode = this.captcha.getResponse();
} else {
  this.captchaChecked = false;
}
console.log(this.captchaChecked);
}

其中 captcha@ViewChild(ReCaptchaComponent) captcha: ReCaptchaComponent;。现在,当验证码过期时,我正在寻找类似的事件。类似于 jquery 中的 data-expired-callback="recaptchaExpiryHeader" 提供的内容。

您可以通过使用回调函数来实现。要捕获到期回调,您需要订阅 handleCaptchaExpiry 事件。

 handleCaptchaExpiry(){
  //   doWhatEver U want.
}

并在您的元素中使用 (captchaExpired)="handleCaptchaExpiry()"angular2-recaptcha 提供获取事件 handleCaptchaExpiry 的方法,当显示的图像过期时触发。它没有任何事件参数。