How to reset only specific fields of form in angular 5

前端 未结 5 2300
名媛妹妹
名媛妹妹 2021-02-19 20:45

I have created a function in one of my component file that resets the form(myform):

`onSubmit() {
  if (this.myform.valid) {
    console.log(\"Form Submitted!\")         


        
5条回答
  •  忘掉有多难
    2021-02-19 21:28

    Yes you can access the controls using this.myform.controls get the control and call reset() on it

提交回复
热议问题