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