resetting reactive form triggers all required validators in Angular 6

后端 未结 2 1952
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-19 23:38

I am new to angular 6 ,Here I am trying to reset the form after submitting the data.

Everything works fine but when I reset the form after successful data submit to

2条回答
  •  悲&欢浪女
    2021-01-20 00:41

    You would need to reset as below:

    In your html:

    In .ts:

    CreateMember(value,formDirective:FormGroupDirective){
     ...
     formDirective.resetForm();
     this.myForm.reset();
    }
    

    Material checks the validity of FormGroupDirective and not of FormGroup hence resetting FormGroup does not reset FormGroupDirective.

    Issue reported here too: https://github.com/angular/material2/issues/9347

提交回复
热议问题