我正在做一个测验,并且我有一个数据库,里面充满了要在前端显示的问题。我能够显示问题的ID,但不能显示实际的问题。这是打字稿代码:
if(this.questionNumber !== this.questions.length - 1){
this.questionNumber++;
this.selectedQuestion = this.questions[this.questionNumber]
console.log(this.selectedQuestion.payload.doc.id)
this.questionAt++;
}
else{
console.log("cant increase on selected array");
}
}
previous(){
if(this.questionNumber !== 0){
this.questionNumber--;
this.selectedQuestion = this.questions[this.questionNumber]
console.log(this.selectedQuestion.payload.doc.id)
this.questionAt--;
}
else{
console.log("cant select -1 from an array");
}
}
并且我试图在以下代码中的id处显示它:
<div class="modal-header">
<h3><span class="label label-warning" id="qid">{{questionAt}}/10</span> {{this.selectedQuestion.payload.doc.id}}</h3>
</div>
答案 0 :(得分:0)
由于要在HTML中显示字符串(问题)数组,因此可以:
<div *ngFor="let question of questions">
{{ question.actualQuestion }}
</div>
显然可以用任何您喜欢的div代替。