reCAPTCHA in Angular2Dart

Issue

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.

Solution

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.

Answered By – Hadrien Lejard

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *