为什么手风琴手风琴没有显示在StackBlitz中?

时间:2020-04-29 15:44:30

标签: angular angular-material

我正在开发一个测验应用程序,当您单击“查看详细摘要”链接时,带有问题和答案摘要的实际手风琴似乎没有显示在我的ResultsComponent中的StackBlitz中。仅显示展开/折叠按钮。请在此处查看我的StackBlitz: https://stackblitz.com/edit/angular-9-quiz-app

1 个答案:

答案 0 :(得分:0)

你有结果

*ngFor="let panel of accordionList; let question of quizData.questions; index as i"

您不能使用* ngFor的这种类型(此外,手风琴列表一无所有)

必须是(我想)

*ngFor="let question of quizData.questions; index as i"

*已更新,您还有另外一个错误提示

 *ngFor="let finalAnswer of finalAnswers;
         let correctAnswer of correctAnswers"

如果您想拥有两个* ngFor,请使用<ng-container>

<div *ngFor="let finalAnswer of finalAnswers">
   <ng-container *ngFor="let correctAndser of correctAnswers>
        ...
   </ng-container>
</div>

或者如果两个数组的长度相同,则使用索引

<div *ngFor="let finalAnswer of finalAnswers;let i=index">
   {{correctAnswers[i]}}
</div>