asyncValidator(control: AbstractControl): {[key: string]: any} {
return new Promise (resolve => {
this.sharedService.checkUserName(control.value).subscribe((result:Result)=>
{
if(result.status)
{
resolve(null);
}
else{
resolve({ validNumber: true });
}
},error=>
{
resolve({ validNumber: true });
});
});
}
this.registerForm = formBuilder.group({
userName:["",
Validators.required,
this.asyncValidator.bind(this)],