google-recaptcha-angular
Version:
Google functionality reCaptcha for Angular
51 lines (41 loc) • 1.25 kB
text/typescript
import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
import {ReCaptchaRenderDirective} from "../re-captcha-render.directive";
export class ReCaptchaGoogleCrearComponent implements OnInit {
onCaptchaSubmit: EventEmitter<any>;
key: string;
render: number;
recaptchaId: string;
recaptchaInst: ReCaptchaRenderDirective;
constructor() { }
ngOnInit() {
this.onCaptchaSubmit = new EventEmitter();
this.render = 2500;
this.recaptchaId = 'grepcatcha';
}
recaptchaRestar() {
if (this.recaptchaInst != null) {
this.recaptchaInst.recaptchaRestar();
}
}
onCaptchaSubmited(data: string) {
if (data != null) {
this.onCaptchaSubmit.emit({
success: true,
token: data,
recaptcha: this
});
} else {
this.onCaptchaSubmit.emit({
success: false,
token: null,
recaptcha: this
});
}
}
}