Skip to content

Instantly share code, notes, and snippets.

@shadow1349
Created February 24, 2023 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shadow1349/021c18ad6e1da465b75eb0d3f6cd3d53 to your computer and use it in GitHub Desktop.
Save shadow1349/021c18ad6e1da465b75eb0d3f6cd3d53 to your computer and use it in GitHub Desktop.
<form #myForm="ngForm">
<div ngModelGroup="user">
<label>
Name:
<input type="text" name="name" [(ngModel)]="name" required>
</label>
<div *ngIf="myForm.controls['user']?.controls['name'].invalid && myForm.controls['user']?.controls['name'].touched">
<div *ngIf="myForm.controls['user']?.controls['name'].errors.required">Name is required</div>
</div>
</div>
<button type="submit">Submit</button>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment