首页 > 解决方案 > 如何将 firebase 的 uid 读取为正常的显示名称?

问题描述

我有这个注册方法:

onSubmit(){

  this.authService.doRegister(this.email.value, this.password.value)
    .then(res => {
      console.log(res);
      this.errorMessage = "";
      this.successMessage = "Your account has been created";
    }, err => {
      console.log(err);
      this.errorMessage = err.message;
      this.successMessage = "";
    })
  }

服务:

doRegister(email, password) {
    return new Promise<any>((resolve, reject) => {
      firebase.auth().createUserWithEmailAndPassword(email, password)
        .then(res => {
          resolve(res);
        }, err => reject(err))
    })
  }

然后是一个显示列表,我希望将帖子与人的实际姓名相关联,而不是这个 userId

     <div class="row">
        <div class="col-md-6">
          <mat-list role="list" *ngFor="let post of posts">
            <mat-list-item role="listitem">Title: {{post.title}}</mat-list-item>
            <mat-list-item role="listitem">Body: {{post.body}} 
</mat-list-item>
            <mat-list-item role="listitem">By: {{post.userId}}</mat-list-item>
                     </mat-list>
        </div>
      </div>

我怎样才能做到这一点?我读过很多死胡同的帖子说这是不可能的。是吗?

标签: angularfirebasefirebase-authentication

解决方案


推荐阅读