0
我想获取并设置一个布尔值为'checkvalue'。我想事先调用函数isItTrue来设置变量'checkvalue'。如果该框被(取消)选中/并且我检查它,它应该调用函数doSomething()。 我正在试验<input type="checkbox" id="{{ class.id }}" ng-init="checkBoxValue=isItTrue(class.id)"[(ngModel)]="class['checkBoxValue']"/>
,但它似乎没有工作。有什么建议么?Angular 4 - 获取和设置模型
<table>
<thead>
<tr>
<th>class</th>
<th>subjects</th>
<th>class speaker</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let class of classes">
<td>{{ class.name }}</td>
<td>
<div class="form">
<input type="text" class="md-input-text" placeholder=" " value=" " [(ngModel)]="subject"/>
<label class="md-desc">subjects</label>
</div>
</td>
<td>
<div class="md-checkbox">
<input type="checkbox" id="{{ class.id }}" [(ngModel)]="class['checkBoxValue']"/>
<label for="{{ class.id }}"></label>
</div>
</td>
</tr>
</tbody>
</table>
ng-init无论如何都不是Angular的东西:) – Vega