angularfire2邮箱密码登录的简单例子
Simple exmple of email password login with anuglarfire2
我的 objective 是构建一个带有 angularfire2 和电子邮件密码身份验证的简单 Angular 应用程序。
我已阅读说明here, and understand that I should read the docs以了解更多方法。但问题是我并没有放弃理解示例应用程序——对我来说,它看起来像是引用了一个不存在的 "this. afAuth"?
你能帮我举个简单的例子吗?或者指引我正确的方向?
这不是 "non-existent this.afAuth
"。它指的是在构造函数中注入的AngularFireAuth
。你需要的是 signInWithEmailAndPassword
method:
login.component.ts
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
方法。
我的 objective 是构建一个带有 angularfire2 和电子邮件密码身份验证的简单 Angular 应用程序。
我已阅读说明here, and understand that I should read the docs以了解更多方法。但问题是我并没有放弃理解示例应用程序——对我来说,它看起来像是引用了一个不存在的 "this. afAuth"?
你能帮我举个简单的例子吗?或者指引我正确的方向?
这不是 "non-existent this.afAuth
"。它指的是在构造函数中注入的AngularFireAuth
。你需要的是 signInWithEmailAndPassword
method:
login.component.ts
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
方法。