这里'n'是增量值,默认情况下为0,当我点击“下一步”时,它增加1 ,分别退出对象
statement 1:
============
#let option of question[0].options
here,lets assume "option" will have 1st question's option. and outputs the
following using *ngFor
**<input name="0" value="{{q1_option_value}}" [(ngModel)]="option_value[0]"
type="checkbox"/><span>{{q1_option_value}}</span>**
**<input name="1" value="{{q1_option_value}}" [(ngModel)]="option_value[1]"
type="checkbox"/><span>{{q1_option_value}}</span>**
=========================
'n' value incremented by 1
=========================
**<input name="0" value="{{q2_option_value}}" [(ngModel)]="option_value[0]"
type="checkbox"/><span>{{q2_option_value}}</span>**
**<input name="1" value="{{q2_option_value}}" [(ngModel)]="option_value[1]"
type="checkbox"/><span>{{q2_option_value}}</span>**
现在,当我在question1的选项中选中一个复选框时,该选择会保持原样 下一个问题也是......
<form>
<div class="choice">
<div *ngFor="let option of question[n].options; let i = index">
<input name="{{i}}" value="{{option}}" [(ngModel)]="option_value[i]"
type="checkbox"/><span>{{option}}</span>
</div>
</div>
</form>
答案 0 :(得分:1)
technologies_value是一个数组吗?如果有,你试过这个吗?
[(ngModel)]="technologies_value[i]"