2017-04-12 15 views
0

저는 Angular Application에서 작업 중입니다. Recaptcha는 응용 프로그램이 초기화되는 동안 잘 작동합니다. 다음 페이지로 탐색 한 후 뒤로 버튼 이벤트 angular2-reCAPTCHA를 내가 angular2-reCAPTCHA를에게Angular2-Recaptcha가 브라우저 백 이벤트에서로드되지 않습니다.

"dependencies": { 
    "@angular/animations": "^4.0.1", 
    "@angular/common": "^4.0.1", 
    "@angular/compiler": "^4.0.1", 
    "@angular/core": "^4.0.1", 
    "@angular/forms": "^4.0.1", 
    "@angular/http": "^4.0.1", 
    "@angular/platform-browser": "^4.0.1", 
    "@angular/platform-browser-dynamic": "^4.0.1", 
    "@angular/router": "^4.0.1", 
    "angular2-recaptcha": "^0.5.0", 
    } 

login.html

<div> 
<re-captcha (captchaResponse)="handleCorrectCaptcha($event)" [site_key]="siteKey" class="captcha"></re-captcha> 
</div> 

로그인을 사용하고 Package.json 파일에서

를로드하지 않는 브라우저를 누른 상태에서 .component.ts

import { ViewChild } from '@angular/core'; 
import { ReCaptchaComponent } from 'angular2-recaptcha'; 
import { Router, RouterModule } from "@angular/router"; 

export class RegisterComponent { 
    @ViewChild(ReCaptchaComponent) captcha: ReCaptchaComponent; 
    constructor(private route: Router,private service:loginservice){ 
    } 
    capcha:any; 
    handleCorrectCaptcha(response: string) { 
    this.service.getCaptcha(response) 
      .subscribe(
      res => { 
      this.capcha=res; 
      this.route.navigate(['/dashboard']); 
      }); 
    } 

} 

모듈

012 3,516,
import { ReCaptchaModule } from 'angular2-recaptcha'; 

@NgModule({ 
    imports: [...,ReCaptchaModule] 
    }) 

답변

1

내가 구성 요소로드 다시

사용 APP_INITIALIZER 사이트 변수를 초기화 할 때 site_key가 초기화되지 않습니다 생각합니다.

체크 아웃 link

+0

어떻게 reCaptcha로 이것을 구현할 수 있습니까? 다른 구성 요소를로드 할 때 Angular2에서 실패합니다. –