Angular Reactive forms : how to reset form state and keep values after submit

前端 未结 7 1814
逝去的感伤
逝去的感伤 2020-12-29 18:42

In an Angular reactive form. How to reset only the state of form after successful submit?

Here is the process:

  • Create the form and
7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-29 19:14

    That's pretty much easy:

    this.form.markAsPristine();
    this.form.markAsUntouched();
    

    This resets the form metadata and the form is pristine again

提交回复
热议问题