[英]Angular 2 Nested *ngFor
I am currently trying to pass some indexes to a function but the first parameter (ii) returns undefined. 我目前正在尝试将一些索引传递给函数,但第一个参数(ii)返回未定义。
<div *ngFor="let tab of screen.data.tabs; let index = i;">
<div *ngIf="tab.active">
<div *ngIf="tab.questions">
<div *ngFor="let question of tab.questions; let index = ii;">
<div class="scenarioContainerQUESTION">
<p [innerHtml]="question.text"></p>
<div *ngFor="let option of question.options; let iii = index;" class="option" [ngClass]="{'optionSelected': option.selected}">
<label [for]="ii+'_'+iii">{{option.text}}</label>
<input [id]="ii+'_'+iii" [name]="'group'+ii" type="radio" [value]="ii" (click)="optionClicked(ii,iii)" />
</div>
<button [ngClass]="{'fade': selectedOption == -1}" (click)="ManageSubmit()">SUBMIT</button>
</div>
</div>
</div>
</div>
</div>
You should assign index value to the variables not the otherway, 您应该将索引值分配给变量,否则,
<div *ngFor="let tab of screen.data.tabs; let i= index;">
also 也
<div *ngFor="let question of tab.questions; let ii= index;">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.