Skip to content

Instantly share code, notes, and snippets.

@Piterden
Forked from ganqqwerty/form.html
Last active June 19, 2019 20:59
Show Gist options
  • Save Piterden/75d480d118062313a8a3e72d58f83210 to your computer and use it in GitHub Desktop.
Save Piterden/75d480d118062313a8a3e72d58f83210 to your computer and use it in GitHub Desktop.
<h2>My form</h2>
<form [formGroup]="myForm" (ngSubmit)="onSubmit()">
<div>
Make email mandatory <input formControlName="myCheckbox"
type="checkbox">
</div>
<div>
Email: <input formControlName="myEmailField"
type="email">
</div>
<button [formAction]="submit">Submit</button>
</form>
<h2>Debug</h2>
<ul>
<li>Is my form valid? {{myForm.valid}}</li>
<li><pre>{{myForm.controls.myEmailField.errors| json}}</pre></li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment