我想用电子邮件和密码创建一个用户--更多的另一个数据,例如,在我的界面中我有这样的名称:
export interface UserInterface {
id?: string;
name: string;
email: string;
password: string;
status: string
constructor(auth) {
this.id = auth.uid
}
}我的服务是:
createUser(user: UserInterface) {
return this.angularFireAuth.auth.createUserWithEmailAndPassword(user.email, user.password)
}我如何在ID中添加属性名称和uid?
发布于 2018-04-25 17:57:30
对我来说,我是这样做的
我有AuthService
createUser(user: UserInterface) {
return this.angularFireAuth.auth.createUserWithEmailAndPassword(user.email, user.password)
.then(() => {
this.service.save(user);
})
.catch((e) => console.log(e));
}在我的UserService里
save(user: any) {
return new Promise((resolve, reject) => {
if(user.key) {
this.db.list(this.PATH)
.update(user.key, ({ name: user.name }))
.then(() => resolve())
.catch((e) => reject(e))
} else {
this.db.list(this.PATH)
.push({ name: user.name })
.then(() => resolve())
}
})
}通过这种方式,我可以在Auth系统中使用电子邮件和密码创建一个用户,并在UserService中向这个用户添加分发器,这样我就做到了!
https://stackoverflow.com/questions/50026734
复制相似问题