Retrieve a list with angularFire and more than one child

走远了吗. 提交于 2020-01-06 05:53:49

问题


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());
    });
});

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.

How do I do it?


回答1:


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.



来源:https://stackoverflow.com/questions/50861021/retrieve-a-list-with-angularfire-and-more-than-one-child

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!