title: How to get form control validation errors in template in Angular
body: <p>I have a form which changes its validation based on some value from the dropdown. If college A is selected then min percentage required in 60, if college B is selected then min percentage drops down to 55.
  Although I have figured out a way to get the min error in the template in so that I didn't have to hard code the percentage value in my template. Although I am not sure if this is the correct way or not.</p>
  
  <pre><code>&lt;div formGroupName="marks"&gt;
    &lt;div class="form-group"&gt;
      &lt;label for="email" class="col-lg-3 control-label"&gt;Semester 1&lt;/label&gt;
      &lt;div class="col-lg-3"&gt;
        &lt;input autocomplete="off"
               #sem1
               type="text"
               min="0"
               max="99"
               maxlength="1"
               maxlength="2"
               class="form-control"
               id="email"
               placeholder="Sem 1 (%)"
               (keypress)="onlyNumberKey($event)"
               formControlName="sem1"&gt;
        &lt;span *ngIf="registrationForm.controls['marks'].controls['sem1'].hasError('required') &amp;&amp;
                     registrationForm.controls['marks'].controls['sem1'].touched"
                     class="text-danger"&gt;
          Sem 1 percentage required
        &lt;/span&gt;
        &lt;span *ngIf="registrationForm.controls['marks'].controls['sem1'].hasError('min') ||
                     registrationForm.controls['marks'].controls['sem1'].hasError('max') ||
                     registrationForm.controls['marks'].controls['sem1'].hasError('minlength')||
                     registrationForm.controls['marks'].controls['sem1'].hasError('maxlength') &amp;&amp;
                     registrationForm.controls['marks'].controls['sem1'].touched"
                     class="text-danger"&gt;
          Percenatge must be {{ registrationForm.get('marks.sem1')._errors.min.min }}  and above.
        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Component</strong> </p>
  
  <pre><code>registrationForm = new FormGroup({
    college: new FormControl('', [
      Validators.required, dropDrownValidator
    ]),
    marks: new FormGroup({
      sem1: new FormControl('',
        [
          Validators.required,
          Validators.min(60),
          Validators.max(99),
          Validators.minLength(1),
          Validators.maxLength(2)
        ]
      )
    })
  });
  </code></pre>