1
2 content_copy
3
4 <input id="name" name="name" class="form-control"
5 required minlength="4" appForbiddenName="bob"
6 [(ngModel)]="hero.name" #name="ngModel" >
7
8<div *ngIf="name.invalid && (name.dirty || name.touched)"
9 class="alert alert-danger">
10
11 <div *ngIf="name.errors.required">
12 Name is required.
13 </div>
14 <div *ngIf="name.errors.minlength">
15 Name must be at least 4 characters long.
16 </div>
17 <div *ngIf="name.errors.forbiddenName">
18 Name cannot be Bob.
19 </div>
20
21</div>
22