Hello I have a little problem that I dont know how to solve, I have asked a question before because things were not obvious to me but they're now, here, I will write my code and try to explain what I want to achieve later.
This is the data in my database :
posts
--- 1
--- puslisher -- "Erick"
--- content : "Something is written here"
--- comments
--- 1
--- comment : "Yes"
--- commentator : "Patrick"
--- 2
--- comment : "I dont think so "
--- commentator : "Sarah"
--- 2
--- puslisher -- "Patrick"
--- content : "News here .."
--- comments
--- 1
--- comment : "Yes"
--- commentator : "Ines"
I get the data in my app.component.ts :
export class AppComponent implements OnInit {
pubs:Observable<any[]>;
constructor(private db:AngularFireDatabase){
}
ngOnInit(){
this.pubs = this.getData('/posts');
}
getData(path):Observable<any[]>{
return this.db.list(path).valueChanges()
}
}
Here is my HTML code :
<div *nfFor="let post of pubs | async ">
<p>publisher {{post.publisher}}</p>
<p>content : {{post.content}}</p>
<div>{{post.comments}}</div>
<ul>
<li *ngFor="let cmt of post.comments" >{{cmt?.comment}}</li>
</ul>
</div>
But as you can see my first object is empty and that is causing problems to :
publisher: Erick
content : Something is written here
,[object Object],[object Object]
-
- Yes
- I don't think so
publisher: Patrick
content : News here
,[object Object]
-
- Yes
This is causing me the problem that you can see in the picture.
Any help would be much appreciated.
