问题
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