Check out example codes for "angular html input validation template driven". It will help you in understanding the concepts better.

Code Example 1

      <input id="name" name="name" class="form-control"
      required minlength="4" appForbiddenName="bob"
      [(ngModel)]="" #name="ngModel" >

<div *ngIf="name.invalid && (name.dirty || name.touched)"
    class="alert alert-danger">

  <div *ngIf="name.errors.required">
    Name is required.
  <div *ngIf="name.errors.minlength">
    Name must be at least 4 characters long.
  <div *ngIf="name.errors.forbiddenName">
    Name cannot be Bob.


Learn ReactJs, React Native from