如何使用 UserId 从Firebase获取当前用户的数据? 我收到的响应为空。我似乎无法正确执行此操作,请帮助。 预先感谢。
import { Component, OnInit } from '@angular/core';
import { AngularFireDatabase, AngularFireList, AngularFireObject } from
'angularfire2/database';
import { Profile } from '../services/profile/profile.model';
import { AngularFireAuth } from '../../../node_modules/angularfire2/auth';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
constructor(private angularFireDatabase: AngularFireDatabase,
private angularFireAuth : AngularFireAuth) {
this.getUserProfile();
}
ngOnInit() {
}
getUserProfile()
{
this.angularFireAuth.authState.subscribe(user => {
this.angularFireDatabase.object('/profiles/' +
user.uid).valueChanges().subscribe(profile => {
console.log(profile)
})
})
}
}
这是我的数据库结构: