I am using angular template driven form. Currently I show the error messages inside the HTML page.
<input
type="email"
name="email"
ngModel
#email="ngModel"
pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$"
required>
<br/>
<div *ngIf="email.touched">
<p *ngIf="email.errors?.required">Email is a required</p>
<p *ngIf="email.errors?.pattern">This is not a valid Email!!!</p>
</div>
Example Form
I need to move these error messages to my component file. is there any way to do it ?