In the template file I'm iterating over an array of elements and for each element a separate row is inserted.
Each element has the same set of controls, but whenever I enter a wrong value inside one of the input fields the same error message appears on all other input controls. I need it to validate only the current input field.
Hope I explained it clearly. Below is my template code:
<tr *ngFor="let element of elements">
<td>
<input matInput
formControlName="elementNamePrefix"
[required]="controls.elementNamePrefix.required"
[placeholder]="controls.elementNamePrefix.displayName"
[type]="controls.elementNamePrefix.type">
<mat-error *ngIf="group.get('elementNamePrefix').hasError('maxlength')">
Max length is XY characters!
</mat-error>
</td>
</tr>