如何获取 angularfire2 中特定键的值?

How to fetch value for a particular key in angularfire2?

这是数据库的结构,我得去取一个value('UID')

this.af.database.object('/profile/' + this.uid).subscribe(profile => {
  console.log(profile);
  this.uid = profile.uid;
  console.log(this.uid);
});

你可以试试这个:

this.af.database.object('/profile/' + this.uid).subscribe(profile => {
var obj = {};
profile.forEach(item => {
obj[item["$key"]] = item["$value"];
});
console.log(obj);
});