[ad_1]
I’m facing a problem in my project, I’m using Nested Children Routing to show data in my project, I want the data of this specific item to be shown once I click the button on it, I did the routing right, it’s just I can’t get the proper function for the items.
Here’s my service
getPostById(id: string){
let docId = this.afs.collection('posts').doc(id).get()
.subscribe( doc => {
if(doc.exists){
console.log('Document Id => ', doc.id)
console.log('Document data => ', doc.data())
}else {
console.log('Document not found')
}
});
return docId; }
and Here’s my TS function for the single item
posts: Posts[] = []; post!:any; constructor(private PostsService: PostsService, private route: ActivatedRoute) { } ngOnInit(): void {
let id = this.route.snapshot.params['id']
this.PostsService.getPostById(id); }
[ad_2]