Solution: Asynchronous Validation
Analyze a possible implementation for the async validation assignment.
We'll cover the following...
We'll cover the following...
The component class
In the component class, we define the reactive form structure.
Line 4: For the
usernamefield, we use the built-in validators to add synchronous validation as defined in the requirements.Line 5: We add the asynchronous validator,
UserValidator.usernameValidator(this.userService). The target service is added as a parameter to reduce the coupling with the custom validator.Line 8: As the
termsfield is bound to a checkbox element in the template, we can use theValidators.requiredTrue...