I have searched through and I still couldn't get the right answer. I will be happy you point me to the right direction.
I have a database with users and projects
pojects:
08177a0acb3f4d96f8cb5fa19002d2ed:
pid: 08177a0acb3f4d96f8cb5fa19002d2ed,
pName: "Prject 1"
uId: "254",
createdAt: 9377476
users:
254:
userName: "Eric"
uId: "254"
avatar: "image.jpg"
Now I want to display my projects, I do a list retrieve in my service
this.projectList = this.af.database.list('projects', {
query: {
orderByChild: 'createdAt'
}
});
getProjects() {
return this.projectList.map(snapshot => {
return snapshot;
});
and I subscribe in the component.ts
this.projectService.getProjects()
.subscribe(projects => this.projects = projects);
What I want to do is get the userName from the users and display it with projects.
How can I use the uId field in projects to retrieve the user info in the users list into one list so I can display i.e {{project.userName}} {{project.avatar}}
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…