使用 angularFire 和多个孩子检索列表

编程入门 行业动态 更新时间:2024-10-09 14:20:53
本文介绍了使用 angularFire 和多个孩子检索列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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:关键词]

本文发布于:2023-04-22 10:19:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1022352.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   孩子   列表   angularFire

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!