Validating on Submitting Form
- Async validators are useful for validating input field in place
- To perform validation on submitting form to the server
<form [formGroup]="form" (ngSubmit)="login()">
<div *ngIf="form.errors">The username or password is invalid</div>
</form>
login() {
//after service response from server
this.form.setErrors({invalidLogin: true})
//this.username.setError({})
}
```