2016-10-18 2 views
0

私は角度2で非同期検証を行いますが、this.subscribe is not a functionを取得しようとしています。_this.subscribeは、角度2の非同期検証の関数ではありません

マイFormGroupは次のとおりです。

const form = new FormGroup({ 
    example: new FormControl('example', [Validators.required], [CustomValidators.example]), 
    last: new FormControl('Drew'), 
}); 

マイカスタム非同期検証

.... 

example (value : number) : AsyncValidatorFn { 
    return (control: AbstractControl): Observable< {[key:string]: boolean} > => { 
    return this.restService.exampleService(value) 
}; 

exampleServiceは検証がひとつにグループ化されなければならない{match: true}

exampleService (value : any) { 
    return this._http.get(AppSettings.API_ENDPOINT + "company/findByNit/" + value) 
     .map(res => res.json()); 
} 

答えて

1

形式でオブジェクトを返しますアレイ。試してみてください

const form = new FormGroup({ 
    example: new FormControl('example', [Validators.required, CustomValidators.example]), 
    last: new FormControl('Drew'), 
}); 
関連する問題