@NoorAlhuda1990 wrote:
Hi my friends . I have news app in ionic4 and i imported all the news from my database in firestore
the problem that i have that i want when i click on the details button it must show the details of each news in a details page ,
i could that passed the id of every news to deatils page but its just show the id As in the following picture![]()
my code :
news.page.tsexport class FilmsPage implements OnInit { news: Observable<any[]>; constructor(public db: AngularFirestore, private router: Router) { } ngOnInit() { this.news = this.db.collection('123').snapshotChanges().map(actions => { return actions.map(a => { const data = a.payload.doc.data(); const id = a.payload.doc.id; return { id, ...data }; }); });news.page.html
<ion-content padding> <ion-item *ngFor=" let count of news | async"> <h5>{{count.title}}<ion-button routerLink="/details/{{count.id}}"> details</ion-button> <img src="{{count.image}}"> </h5> </ion-item> </ion-content>details.pge.ts
export class DetailsPage implements OnInit { id: string; constructor(private router: ActivatedRoute, private afs: AngularFirestore) { } ngOnInit() { this.id = this.router.snapshot.paramMap.get('id'); console.log(this.id); } }details.page.html
<ion-content padding > {{id}} </ion-content>
Posts: 1
Participants: 1
