简体   繁体   中英

How to fetch value for a particular key in angularfire2?

firebase数据结构

This is the structure of database, I have to fetch one 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);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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