Created
March 7, 2019 14:29
-
-
Save ngohungphuc/d758809a3498f473cc75dbf1bb87f7c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form [formGroup]="myForm"> | |
<div> | |
<input type="text" class="form-input" [ngModel]="name" formControlName="name" /> | |
</div> | |
<label class="form-group err-msg" *ngIf="myForm.get('name').hasError('required') && (name.get('name').dirty || myForm.get('name').touched)">Name is required</label> | |
<label class="form-group err-msg" *ngIf="myForm.get('name').hasError('whitespaces') && (name.get('name').dirty || myForm.get('name').touched)">Name is required</label> | |
<div> | |
<input type="text" class="form-input" [ngModel]="email" formControlName="email" /> | |
</div> | |
<label class="form-group err-msg" *ngIf="myForm.get('email').hasError('required') && (myForm.get('email').dirty || myForm.get('email').touched)">Email | |
is required</label> | |
<button type="submit" disabled="!myForm.valid">Submit</button> | |
</form> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment