Using Async Validators

In this lesson, we'll apply the async validator we created to the form control for the password.

We’re going to use the validator we created.

validate = (control: FormControl) => {

In the validate function, we’ve annotated the control parameter with the FormControl class. We’ll want to apply this validator to a form control. The form control we’ll be applying it to is the control for the password. Before we do, we’ll need to make the class injectable.

Dependency injection

We’ll import the Injectable decorator to tell Angular that the validator is injectable. We’ll update the compromised-password.ts file to the following:

Get hands-on with 1200+ tech skills courses.