this.afAuth
“。它是指
AngularFireAuth
注入构造函数中。你需要的是
signInWithEmailAndPassword
method
:
export class LoginComponent {
constructor(private afAuth: AngularFireAuth) {}
login(email: string, password: string): void {
this.afAuth.auth.signInWithEmailAndPassword(email, password)
.then(() => console.log('logged in'))
.catch((err: Error) => console.error(err.message));
}
}
然后,只需在表单中传递凭据(电子邮件、密码),然后拨打
login