1

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.

marcg
  • 552
  • 1
  • 8
  • 20
  • Is it possible to post more code about how you try to use recaptcha inside you component ? – Hadrien Lejard Dec 28 '16 at 13:43
  • Only code I have in component is '
    '. 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 Dec 28 '16 at 23:47

1 Answers1

1

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.

Hadrien Lejard
  • 5,644
  • 2
  • 21
  • 18
  • When I tried to use it, I get this error - Loading angular2 and dart_to_js_script_rewriter transformers... Serving captcha web on http://localhost:54136 [DirectiveProcessor on captcha|lib/app_component.dart]: ERROR: Invalid argument (absoluteUri): Value passed must be an absolute uri: – marcg Jan 05 '17 at 02:43
  • Can you try with the last version `0.0.3` ? if you still have issue, put it on github, it is better than here. – Hadrien Lejard Jan 05 '17 at 12:22
  • Here is a sample demo i did using @HadrienLejard component - https://sureshg.github.io/recaptcha-ng2dart/ – Suresh Jan 07 '17 at 23:51