问题描述
限时送ChatGPT账号..我正在使用 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
|...
如果我使用下面的方法,我只能得到一个subsection",而不是其他孩子......
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屋!
更多推荐
[db:关键词]
发布评论