1
How to go through data from an Observable and insert into a list?
I would like to compile a list of all the arrays within Observable that comes from Cloud Firestore, because I need a list of people to display in Mattabledatasource.
export interface Pessoa {
nome: string;
cidade: string;
}
export MyClass {
list_pessoa: Pessoa[] = [];
pessoa: Observable<Pessoa[]>;
constructor(){
// Algo parecido como isso, mas que funcione!
this.pessoa.forEach(v =>{
const d = v.values()
this.list_pessoa.push(d);
})
console.log(this.list_pessoa);
}
}
Exit:
list_person [
{'name': 'person1', 'city': 'city1'},
{''name': 'people2', 'city': 'city2'}
]
- What is the best way to go through the data inside the Observable and insert into a list of arrays?
Hello Arnaldo, I thank you from now on the intention to want to help but you are not returning anything from the Observable using subscribe, take a look above at the method that returns the Observable if necessary.
– Luiz Ricardo Cardoso