更新时间:2023-12-01 16:40:10
也许这是因为你在回调函数中使用这个
关键字,它有自己的变量作用域,它没有 af.auth
属性。
Maybe this is because you are using this
keyword in callback function which has its own variable scope and it does not have af.auth
property.
试试这个。
Try this.
public login() {
var me = this;
this.af.auth.login()
.then(() => {
console.log("user logged in");
console.log(me.af.auth);
});
}
尝试订阅 auth
对象,并且应该通知auth状态更改。
Try to subscribe on auth
object and you should be notified on auth state change.
this.af.auth.subscribe(auth => {
if(auth) {
console.log('logged in');
} else {
console.log('not logged in');
}
});