For now I am using @Input() to pass error messages from parent to child component that implements ControlValueAccessor. I would like to know is there better way of passing error messages. Please guide me. Thank you

<mat-form-field class="increment">
    <input 
        matInput 
        [formControl]="_control.control"
        type="text" 
        [disabled]="disabled"
        [max]="max" 
        [min]="min"
        [errorMessage]="errorMessage" 
        [(ngModel)]="value"/>
       
</mat-form-field>

Let me know if you know how it can be done

1

There are 1 best solutions below

0
On

Try using setError() provided by the ControlValueAccessor interface. Refer this link to understand the concept behind this: https://indepth.dev/posts/1143/a-thorough-exploration-of-angular-forms