I've been looking for solutions but non worked for my application, I'm trying to build a Quiz app using angular and firestore with angularfire, my current approach:
public getRandomQuestion(): Promise<any> {
let ques: IQuestion;
return this.firestore.collection('questions', ref => ref.where('randId', '>=', this.getRandomInt(1,999999)).limit(1)).valueChanges().toPromise();
}
public getTenRandomQuestion(): IQuestion[]{
let obs : IQuestion[] = [];
for (let i: number = 0; i <= 9; i++){
this.getRandomQuestion().then(res => {
obs[i] = res;
});
}
console.log(obs);
return obs;
}
But it always returns an empty array, here's my firestore : Firestore
Aucun commentaire:
Enregistrer un commentaire