Creating a Reusable Display for Validation Errors and Scrolling to the First Error in Angular Forms

Form Validation is a must for any kind of form-Template or Reactive. We really don’t want to write 10–15 lines of HTML code for displaying error messages. In the story, we are going to see, how an error component can be used to keep the code clean.

TemplateFormComponent:

<form class=”form-group” #TempForm=”ngForm” (ngSubmit)=”submitForm(TempForm)”><label>Enter some text:</label>
<input class=”form-control”…