Validating workout names using async validators

Like custom validators, async validators inherit from the same Validator class too; but this time, instead of returning an object map, async validators return a Promise.

Let's look at the definition of the validator. Copy the definition of the validator from the GitHub (http://bit.ly/ng6be-6-1-remote-validator-directive-ts) folder and add it to the shared module folder. The validator definition looks as follows:

import { Directive, Input } from '@angular/core';import { NG_ASYNC_VALIDATORS, FormControl } from '@angular/forms';@Directive({  selector: '[abeRemoteValidator][ngModel]',  providers: [{ provide: NG_ASYNC_VALIDATORS, useExisting: RemoteValidatorDirective, multi: true }]})export class RemoteValidatorDirective ...

Get Building Large-Scale Web Applications with Angular now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.