I have one form where I need to set the fields to valid or invalid, because I want to edit the user, but the button stay disabled
edit.component
ngOnInit() {
this.getForm();
this.getRole();
console.log(this.formGroup.valid)
}
getForm() {
this.formGroup = this.formBuilder.group({
name: ['', Validators.required],
label: ['', Validators.required],
});
}
when I'll go to the page edit I would like abilit the button I need to set invalid the form
<button type="submit" mat-button color="primary" [disabled]="!formGroup.valid">Alterar</button>
for example
if(user) {
this.formGroup (invalid)
} else {
this.formGroup (valid)
}
this is my page to edit item, but the formgroup is invalid even with the field filled in, why ?