【发布时间】:2020-09-07 01:12:34
【问题描述】:
Hola 开发人员正在使用 angular 和 firebase 开发此应用程序,我已经更新了用户创建的显示名称,但现在尝试将该名称保留在我的 firestore 中,我遇到了一些问题。
Service class where in i access my firstore and my fireauth modules
export class LoginService {
constructor(
private userLogin: AngularFireAuth,
private docCreator: AngularFirestore
) {}
signUpUser(emailUser: string, passwordUser: string) {
return new Promise((response, reject) => {
this.userLogin
.createUserWithEmailAndPassword(emailUser, passwordUser)
.then(
(responseOk) => {
this.userdata.uid = responseOk.user.uid;
this.userdata.restData = responseOk.user;
responseOk.user.updateProfile({
displayName: 'nameUpdated'
}).then(() => {
console.log('displayname setted');
response(responseOk);
});
let userDoc = this.docCreator
.collection('users')
.doc(responseOk.user.uid);===variable accessing my collection and doc of user created====
userDoc.set({
amountInAccount: 0,
userName:responseOk.user.displayName(HERE THE ISSUE)
});===trying to store in my new user created doc the displayname already updated====FAIL!!!
}
因此,基本上在这个服务中,我只是尝试通过在我的构造函数 FirestoreModule 中初始化的变量访问显示名称,然后通过路径(集合/文档)到达我想要设置新名称的地方使用方法集,并访问在 firestore i 中创建的密钥 用我的新 displayName 更新,但不起作用。 关于如何改进这一点的任何想法。提前谢谢!!!
【问题讨论】:
标签: angular firebase google-cloud-firestore