i'm not able to fetch data from firebase on mat table
from component ts
getAllStudent() {
this.service.getAllStudent().subscribe((data: any)=>{
console.log(data.payload)
this.students = data.map((e: { payload: { doc: { id: any; data: () => any; }; }; }) => {
return {
$key:e.payload.doc.id,
...e.payload.doc.data()
}as Student;
});
console.log(this.students);
this.studentData = new MatTableDataSource(this.students)
this.studentData.paginator = this.paginator;
});
}
this form service
getAllStudent() {
let userid : any = '';
userid = window.localStorage.getItem("userid")
console.log(userid)
return this.firestore.collection('School').doc(userid).snapshotChanges();
}
0 Answer(s)