相关疑难解决方法(0)

如何重置Angular Reactive Form

我尝试过但未能找到重置角形的方法.

有人可以帮忙吗?

<form #thisIsAForm>
  <mat-form-field class="full-width">
    <input matInput placeholder="Weather">
  </mat-form-field>
</form>
<button mat-raised-button (click)="resetForm()">Reset</button>

export class Example{
  @ViewChild('thisIsAForm') thisIsAForm;

  resetForm() {
    this.thisIsAForm.reset();
  }
}
Run Code Online (Sandbox Code Playgroud)

angular angular-reactive-forms

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

angular ×1

angular-reactive-forms ×1