1
votes

I am trying to use google reCAPTCHA in an Angular2dart app. In index.html I have

https://www.google.com/recaptcha/api.js'>

component's mark-up has -

div class="g-recaptcha" data-sitekey=" site key val ">

However captcha is not displayed in Dartium even after refresh. If I build the app using pub build, deploy it to a container, and then access it using Chrome or other browsers, captcha is not displayed the first time but upon refresh, captcha is displayed. Is there a Dart library similar to Angular recaptcha (https://github.com/VividCortex/angular-recaptcha)?

Moreover, how can I access reCaptcha response in the controller ? I tried using

@ViewChild('heroForm') NgForm heroForm;

but heroForm.value map does not contain reCaptcha response.

1
Is it possible to post more code about how you try to use recaptcha inside you component ?Hadrien Lejard
Only code I have in component is '<div class="g-recaptcha" data-sitekey=" site key val ">'. If I put this line of code in index.html, captcha is displayed. but if I put this code in component, it is not displayed.marcg

1 Answers

1
votes

Take a look at this https://github.com/lejard-h/angular_recaptcha

The problem is that the component is load after the recaptcha script, so you have to render the captcha by yourself.

I did a simple component but without the full form integration, feel free to fork and pull request.