我正在制作一个测验应用程序,我只想从消防站里拿一个随机物品。我已经制作了随机数生成器,但是我不知道如何从这里继续。
打字稿:
import { Injectable } from '@angular/core';
import { AngularFirestore } from '@angular/fire/firestore';
@Injectable({
providedIn: 'root'
})
export class CrudService {
constructor(
private firestore: AngularFirestore
) { }
create_NewQuiz(record) {
return this.firestore.collection('Quizzes').add(record);
}
read_Quizzes() {
let numberOfQuestion = 5;
let randomQuestion = Math.floor(Math.random() * numberOfQuestion);
return this.firestore.collection('Quizzes').snapshotChanges();
}
update_Quiz(recordID,record){
this.firestore.doc('Quizzes/' + recordID).update(record);
}
delete_Quiz(record_id) {
this.firestore.doc('Quizzes/' + record_id).delete();
}
}