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

时间:2017-04-11 21:04:51

标签: angular firebase firebase-realtime-database angularfire2

firebase Data structure

这是数据库的结构,我必须获取一个this.af.database.object('/profile/' + this.uid).subscribe(profile => { console.log(profile); this.uid = profile.uid; console.log(this.uid); });

# Getting Started
# Heading 1
## SubHeading 1
## SubHeading 2
### SubSubHeading 1
### SubSubHeading 2
#### SubSubSubHeading 1
## SubHeading 3

1 个答案:

答案 0 :(得分:1)

你可以试试这个:

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