我試圖在特定測驗中顯示用戶所做的錯誤答案。但它不會在我的HTML中顯示數據。我在這裏做錯了什麼?在數組中顯示值不會顯示在視角中
<ion-slide *ngFor="let incorrect of wrongAnswers;let i=index">
<ion-label>{{i+1}}</ion-label>
<h5>{{incorrect.questionA}}</h5>
<h5>{{incorrect.choice}}</h5>
<h5>{{incorrect.answer}}</h5>
<button ion-button (click)="error()"></button>
</ion-slide>
我的打字稿:
wrongAnswers: any[] = [];
if (answer.correct == false) {
this.wrongAnswers.push([{
questionA: question.questionText,
choice: answer.selected,
answer: answer.answer
}]);
}
在我的控制檯,這是正在顯示的內容:
嘗試刪除'[]'圍繞着你推,即'.push({...})的對象;'。 – Parziphal