3
github apiで非同期検証を実装する必要があります。あなたが私を助けてくれることを願っていますAngular2ユーザー名または電子メールの非同期検証
export class UsernameValidator {
static usernameTaken(control: FormControl): Promise<ValidationResult> {
return new Promise((resolve, reject) => {
setTimeout(() => {
//How Can i use github Api like this:
// if (control.value === "this._http.get('http://api.github.com/users/'+this.username)")) {
if (control.value === "David") {
console.log('username taken')
resolve({"usernameTaken": true})
} else {
resolve(null);
};
}, 1000);
});
}
}
ありがとうございます。
あなたは私の一日行わ!ありがとうございました。それは非常に涼しい動作します –
@AlexanderBorovoi私の質問を確認してください私は非常に似たような状況がありますhttp://stackoverflow.com/questions/40756441/custom-async-validation-not-working-when-returning-a-promise – Luther
あなたはあなたの例にデバウンス時間を加えてください。私はすべてのキープレスでhttpリクエストを送信したくない。 – Michalis