reCAPTCHA不会显示[angular2]

时间:2016-04-22 08:35:36

标签: html typescript angular captcha recaptcha

我正在尝试使用TypeScript为我的Angular2应用实现谷歌reCAPTCHA。

我尝试按照指南here以及official documentation进行操作,但reCAPTCHA根本没有显示。

这是html;

<form *ngIf="showForm" [ngFormModel]="form" (submit)="onSubmit(email.fromName, email.fromEmail, email.message)">
<div class="wrapper">
  <label for="msg">Message</label>
  <br/>
  <textarea required type="text" [(ngModel)]="email.message" placeholder="Description"  ngControl="msgCtrl"></textarea>
  <div class="msgError" *ngIf="msgCtrl.dirty && !msgCtrl.valid">
    <div *ngIf="msgCtrl.errors.minlength" class="formError">
    <i class="fa fa-exclamation-triangle"></i> Your message needs to be longer.
    </div>
  </div>

  <div class="contactInfo">
    <h3>Please supply your contact info here</h3>
    <label for="email">Email</label>
    <br/>
    <input required type="text" [(ngModel)]="email.fromEmail" placeholder="Your mail" ngControl="emailCtrl"/>
    <div class="emailError" *ngIf="emailCtrl.dirty && !emailCtrl.valid">
    <div *ngIf="emailCtrl.errors.isInCorrectEmail" class="formError">
      <i class="fa fa-exclamation-triangle"></i> Invalid format.
    </div>
    </div>
    <br/>
    <label for="name">Name</label>
    <br/>
    <input required type="text" [(ngModel)]="email.fromName" placeholder="Your name" ngControl="nameCtrl"/>
  </div>
</div>

<div class="buttonArea">
  <div class="g-recaptcha" data-sitekey="MY KEY"></div>
    <button type="submit" [disabled]="!form.valid">Submit</button>
    <div class="formError" *ngIf="error === true" role="alert">
  <i class="fa fa-exclamation-triangle"></i> Couldn't send.
  </div>
</div>

我已尝试放置

<div class="g-recaptcha" data-sitekey="MY KEY"></div>

在代码的不同区域(几乎所有div之内和之外)只是为了看它是否会出现。

我在index.html文件中导入脚本,我导入所有其他可以正常工作的脚本。

感谢您的帮助!

0 个答案:

没有答案