From d3a8409cc6578258c1f0d6e0e153c5bb77a583e4 Mon Sep 17 00:00:00 2001 From: Ivan Pankratov Date: Sat, 23 Dec 2017 14:48:42 +0500 Subject: [PATCH] fix(component): use ElementRef to access component's native element Closes #48, #68 --- recaptcha/recaptcha.component.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/recaptcha/recaptcha.component.ts b/recaptcha/recaptcha.component.ts index 026a286..300bc2c 100644 --- a/recaptcha/recaptcha.component.ts +++ b/recaptcha/recaptcha.component.ts @@ -1,6 +1,7 @@ import { AfterViewInit, Component, + ElementRef, EventEmitter, HostBinding, Inject, @@ -44,6 +45,7 @@ export class RecaptchaComponent implements AfterViewInit, OnDestroy { private grecaptcha: ReCaptchaV2.ReCaptcha; constructor( + private elementRef: ElementRef, private loader: RecaptchaLoaderService, private zone: NgZone, @Optional() @Inject(RECAPTCHA_SETTINGS) settings?: RecaptchaSettings, @@ -121,7 +123,7 @@ export class RecaptchaComponent implements AfterViewInit, OnDestroy { /** @internal */ private renderRecaptcha() { - this.widget = this.grecaptcha.render(this.id, { + this.widget = this.grecaptcha.render(this.elementRef.nativeElement, { badge: this.badge, callback: (response: string) => { this.zone.run(() => this.captchaReponseCallback(response));