I'm getting crazy with this, so I submit to the audience.
I need to return an Observable. I first call Firestore to retrieve a field that contains an array and then based on each value of the array, I want to retrieve the matching key. Fairly easy usually.
I see exactly what I cant on the console, so data are here, but why the hell they never show up in the view. Before I gave up, I made countless variations of the below.
My Service – Edited to reflect suggestions. Still not working
getUserActivites() {
console.log(this.userId)
let array = []
const agenda = this.afs.doc(`users/${this.userId}`).snapshotChanges()
agenda.subscribe(list => {
const data = list.payload.data().activities
data.map(event => {
const id = event
const dataRef = this.afs.doc(`activities/${event}`).valueChanges()
dataRef.subscribe(date => {
array.push(date)
console.log(array) //array log the expected data in an array of Object
return data
})
})
})
return agenda
}
My Component
public agendaData: Observable<any>
then in constructor
this.agendaData = this.agenda.getUserActivites()
My View
<div *ngFor="let item of agendaData | async ">
{{ item.name }}
</div>