Skip to content

Commit

Permalink
#1 recaptcha component: move initialization in AfterViewInit
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Jun 16, 2019
1 parent d7c06d8 commit 9ddc18e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/app/recaptcha/recaptcha.component.html

This file was deleted.

10 changes: 5 additions & 5 deletions src/app/recaptcha/recaptcha.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Input, ElementRef, OnDestroy, ViewChild, Output, EventEmitter } from '@angular/core';
import { Component, Input, ElementRef, OnDestroy, ViewChild, Output, EventEmitter, AfterViewInit } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Subscription } from 'rxjs';

Expand All @@ -9,24 +9,24 @@ let idCallback = 0;

@Component({
selector: 'app-recaptcha',
templateUrl: './recaptcha.component.html'
template: '<div #targetElement class="c-container"></div>'
})
export class RecaptchaComponent implements OnInit, OnDestroy {
export class RecaptchaComponent implements OnDestroy, AfterViewInit {

@Input()
apiKey: string;

private langSub: Subscription;

@ViewChild('targetElement')
private targetElement: ElementRef;
private targetElement: ElementRef<HTMLDivElement>;

@Output()
recaptchaResponse: EventEmitter<string> = new EventEmitter<string>();

constructor(private translate: TranslateService) { }

ngOnInit() {
ngAfterViewInit() {

if (!document.getElementById('recaptcha-api-script')) {
const scriptElem = document.createElement('script');
Expand Down

0 comments on commit 9ddc18e

Please sign in to comment.