使用angularFire和一个以上的孩子检索列表 [英] Retrieve a list with angularFire and more than one child
问题描述
我正在使用angularFire将页面连接到数据库.我想以页面列表的形式显示存储在我的Firebase数据库中的所有用户.我存储这些用户的方式是这样的:
I'm using angularFire to connect my page to my database. I want to display all the users stored in my firebase database in the form of a list on a page. The way I am storing these users is like this :
users
|_date1
| |_hour1
| |_email:name
|_date2
| |_hour2
| |_email:name
|...
如果我使用下面的方法,我只能得到一个小节",而不能得到另一个孩子……
if I use the method below, I can only get one "subsection", not the other children...
this.fireDB.list('users').snapshotChanges().subscribe(res => {
res.forEach(doc => {
this.credentialsArray.push(doc.key, doc.payload.val());
});
});
我需要使用Credetial
模型将其放入我的credentialsArray
中,以便可以在表中列出它:
I need to put this in my credentialsArray
with the Credetial
model, so I can list it in my table:
this.credentialsArray.push(new Credential('name', 'email'));
我也想知道时间和日期.
And I want to get the time and date too.
我该怎么做?
推荐答案
您可以在调用方法之前先将数据放在对象Credential
中:
You can put data first in your object Credential
before call in method:
this.fireDB.list('users').snapshotChanges().subscribe(res => {
res.forEach(doc => {
Credential cred = doc;
this.credentialsArray.push(cred);
});
});
检查您的对象是否准备好检索所有数据类型.
Check if your object are ready for retrieve all data types.
这篇关于使用angularFire和一个以上的孩子检索列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!