【发布时间】:2018-08-01 13:29:42
【问题描述】:
我可能正在监督某些事情,但我被卡住了,以下变量在 promise 中更新它们的值时似乎没有在模板中更新:
private emailDetected: boolean = false;
private detectedEmail: string = "";
detectEmailViaPassword() {
this.afAuth.auth.signInWithPopup(new auth.GoogleAuthProvider()).then(authResult => {
this.detectedEmail = authResult.user.email;
this.emailDetected = true;
}).catch(error => {
console.log(error);
});
}
记录变量时,它们似乎已更新,但模板中没有发生任何事情。当我从 firebase auth 承诺之外的其他地方更新变量时,它可以正常工作——我非常困惑......
在模板中正确引用了变量:{{ detectedEmail }}
我将非常感谢您的帮助:)
【问题讨论】:
-
如果我没记错的话,将变量设置为
private这意味着它们无法在模板中访问。这表明它们对于class打字稿文件是私有的。
标签: angular typescript