I'm trying to remove a Validators.required
in order to make a form valid. But whatever I do, none of that is happening
Here is my logic:
form = new FormGroup({
name: new FormControl('', [Validators.required]),
type: new FormControl('test', [Validators.required]),
});
this.form.get('name').clearValidators();
this.form.updateValueAndValidity();
this.cdr.detectChanges();
Whatever I do, the form.valid
is always false. Any suggestions why the form.valid
property is not true
?
You need to call updateValueAndValidity on individual control
this.form.get('name').clearValidators();
this.form.get('name').updateValueAndValidity();