Is it possible to use Validators in the ts.file to display an error message when a field is invalid, rather than directly in the html?
Thanks.
html
<form [formGroup]="form">
<mat-form-field>
<mat-label>Nom</mat-label>
<input matInput formControlName="nom"/>
<div *ngIf="form.get('nom')?.invalid"> error </div> // display this error in ts.file
</mat-form-field>
</form>
ts.file
formulaire(): FormGroup {
this.form = this.fb.group({
nom: ['', [Validators.required]]
})
}