I have an input I would like to add errorText to. I would like to provide different error messages based on what is wrong with the input. Currently I have a getter on the [errorText] binding that checks the error and responds with the appropriate string. This seems like a super expensive operation since the method gets called repeatedly, even when there is no error on the input. What’s the intended way of adding specific error messages?
<ion-input type="email" id="email" formControlName="email" required
label="Email" labelPlacement="floating" [errorText]="emailErrorText"
></ion-input>
get emailErrorText() {
if (this.email.hasError('required')) {
return 'Email is required.';
} else if (this.email.hasError('sytnax')) {
return 'Email is invalid.';
} else if (this.email.hasError('duplicate')) {
return 'Email is already in use.';
}
return null;
}