简体   繁体   English

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

[英]How to fetch value for a particular key in angularfire2?

firebase数据结构

This is the structure of database, I have to fetch one value('UID') . 这是数据库的结构,我必须获取一个value('UID')

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

You can try this: 您可以尝试以下方法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM