Angular custom validator apply template for repetitive code
问题 I have multiple input fields where almost same validation is required. Is there any way to reduce repetitive HTML code for displaying error. My code is as below <div colspan="2"> <input type="text" name="appName" [disabled]="recordCreated" [(ngModel)]="appName" appForbiddenName="Application" minlength="4" required #name="ngModel" [ngClass]="{'has-danger': name.invalid && (name.dirty || name.touched) }" /> <div *ngIf="name.invalid && (name.dirty || name.touched)" class="alert alert-danger">