Html TypeError:无法读取属性';问题';未定义的

Html TypeError:无法读取属性';问题';未定义的,html,angular,typescript,Html,Angular,Typescript,我收到了上面的错误信息,但我不明白为什么,因为就我所知,一切都被定义了 这是我的html: 显然,错误发生在第1行 <div *ngIf="pager.index < quiz.questions.length"> <h5 class="flow-text"><span [innerHTML]="quiz.questions[pager.index].text"></span></h5> <br> <

我收到了上面的错误信息,但我不明白为什么,因为就我所知,一切都被定义了

这是我的html:

显然,错误发生在第1行

<div *ngIf="pager.index < quiz.questions.length">
  <h5 class="flow-text"><span [innerHTML]="quiz.questions[pager.index].text"></span></h5>
  <br>
  <div class="row text-left">
    <div class="col s12 m12" *ngFor="let answer of quiz.questions[pager.index].answers">
      <div class="answer">
        <input type="checkbox" [checked]="answer.selected" (change)="onSelect(answer);"/><label class="black-text flow-text"> {{answer.text}} </label>
      </div>
    </div>
  </div>
  <footer class="row">
    <div class="col s6 m6"></div>
    <div class="col s6 m6">
      <div *ngIf="pager.index < quiz.questions.length - 1">
        <button id="nextButton" class="btn-flat black-text right flow-text" (click)="goTo(pager.index + 1);">Next</button>
      </div>
      <div *ngIf="pager.index == quiz.questions.length - 1">
        <button id="nextButton" class="btn-flat black-text right flow-text" (click)="goTo(pager.index + 1);">Finish</button>
      </div>
    </div>
  </footer>
</div>

<div *ngIf="pager.index == quiz.questions.length">
  {{ selections }}
</div>

除了我在另一个问题中询问的复选框之外,我不明白为什么它会发生,尽管编译代码时出现了错误,但它仍能正常工作和运行。

似乎
quick
变量是
未定义的
,定义如下
quick:quick={}

似乎
测验
变量是
未定义的
,定义如下
测验:测验={}

在这种情况下,您应该使用安全导航操作符

*ngIf="pager.index < quiz?.questions?.length"

在这种情况下,您应该使用安全导航操作符

*ngIf="pager.index < quiz?.questions?.length"

测验似乎没有定义。测验的可能副本似乎没有定义。非常感谢的可能副本,当stack让我这么想你时将接受答案,当stack让我这么想你时将接受答案
*ngIf="pager.index == quiz?.questions?.length"