0
電子メールが既に送信されているかどうかを私のサーバーからの回答を待つ必要があります。しかし、私はこれを同期させるのに苦労しています。私のifステートメントでは、typescriptはisCorrectEmail()はvoid関数(私は理解できますが解決できない)だと言います。何か案が?Angular2 - 条件文の中で約束する
isEmailAvailable(){
return new Promise((resolve, reject) => {
this.authService.checkemail(this.user.email).then(result => {
let res = <any> result;
if (res.code == 0){
resolve(true);
}
else resolve(false);
}, (err) => {
reject(false);
});
});
};
isCorrectEmail(){
this.isEmailAvailable().then((result) => { return result ; });
};
checkPersonalInfos()
{
if (this.isCorrectEmail() == true){...}
..
}
[避けてください'Promise'コンストラクタ反パターン](https://stackoverflow.com/q/23803743/1048572?What-is-the-promise-construction-antipattern-and-how-to-avoid-it)! – Bergi