January 2018
Intermediate to advanced
348 pages
8h 17m
English
In our issue's reactive form template, we define two input fields for the label and description of the issue and a dropdown for selecting the user. These three inputs are marked as required, and thus we also need to display validation errors if the input has been touched and is invalid:
<form [formGroup]="issueForm" (ngSubmit)="onSave()">... <input type="text" class="form-control" id="label" formControlName="label"> <span *ngIf="issueForm.get('label').touched && issueForm.get('label').hasError('required')"> Label is required </span> <input type="text" class="form-control" id="description" formControlName="description"> <span *ngIf="issueForm.get('description').touched && issueForm.get('description').hasError('required')"> Description ...