Angular 5 + materializecss表单重置

时间:2018-02-12 13:41:08

标签: materialize angular5

我有一个用于添加新用户的表单,我遇到表单重置问题,因为它没有删除有效的实现类。

表格:

<div class="col s12 m12 l4 xl4">
      <form (ngSubmit)="onSubmit(); newLabMember.reset()" #newLabMember="ngForm" ngNativeValidate>
        <!-- New lab member form -->
        <div class="section">
          <h5>Add lab member</h5>
          <div class="input-field">
            <input type="text" name="firstName" [(ngModel)]="user.firstname" class="validate" id="firstName" validate required>
            <label for="firstName">First name</label>
          </div>
          <div class="input-field">
            <input type="text" name="lastName" [(ngModel)]="user.lastname" class="validate" id="lastName" validate required>
            <label for="firstName">Last name</label>
          </div>
          <div class="input-field">
            <input type="text" name="email" [(ngModel)]="user.email" class="validate" id="email" validate required>
            <label for="email">Member email</label>
          </div>
          <blockquote>An email will be sent to the new user with a password and further instructions.
            </blockquote>
          <div class="input-field">
            <button type="submit" class="waves-effect waves-light btn blue-grey darken-1">Add new member</button>
          </div>
        </div>
      </form>
    </div>

正如您所看到的,当我提交表单时,我使用了reset()表单,但仍然存在类似.valid的实现。

0 个答案:

没有答案