表格在RC5中提交两次

时间:2016-08-12 02:27:35

标签: angular angular2-template

此表单两次调用onSubmit() 我没有配置任何路由或任何其他instatiations 不确定RC5或其他问题是否存在问题?

<form *ngIf="postingMessage" (ngSubmit)="onSubmit()" #msgForm="ngForm">
        <div class="form-group">
              <h3>New Message</h3>
             <label>Subject:</label><br>
              <input [(ngModel)]="postingMessage.subject" 
              class="form-control"
              type="text" 
              id="subject"
              name="subject" 
              #subject="ngModel"
              required
              autofocus
              size="80"
              [ngClass]="{invalid: subject.touched && !subject.valid}">
              <br>
              <div [hidden]="subject.valid || subject.pristine" 
              class="alert alert-danger">
              Subject is required
              </div>
              <label>Message:</label><br>
              <textarea [(ngModel)]="postingMessage.body" class="form-    control" rows="10" cols="80" name="body" required></textarea>
        </div>
          <button type="submit" [disabled]="!msgForm.form.valid">Save</button>
    </form>

0 个答案:

没有答案