- Validators classes: https://angular.io/api/forms/Validators
- Validators directives: https://angular.io/api?type=directive (search for the word "Validator")
<form (ngSubmit)="onSubmit( f )" #f="ngForm">
In the code we can access this form as:
onSubmit( form : NgForm ) {
console.log( form );
}
<div class="form-group">
<label for="email">Mail</label>
<input
type="email"
id="email"
class="form-control"
ngModel
name="email"
required email
#email="ngModel">
<span class="help-block" *ngIf="!email.valid">Please enter a valid email</span>
</div>