I am currently trying to convert an Observable into an Array so that I can iterate over the Array in HTML using ngFor.
This is my Typescript code currently. When I console log the testArray Array it is saying it is undefined.
item$: Observable<any[]>;
testArray: Array<any[]>;
constructor(
private afs: AngularFirestore,
private route: ActivatedRoute,
) {
this.item$ = afs.collection('testsTaken', ref => ref.where('testCreator', '==', this.id).where('testTitle', '==', this.testTitle)).valueChanges();
this.item$.subscribe(x => this.testArray = x);
console.log(this.testArray); // yields undefined
}
I tried the advice given for this post and I still cant get it to work