0
我有一個表格,其中一列是我需要激活的複選框,取決於特定的邏輯。如何避免在點擊表格行時選中複選框
我的問題是,即使當複選框被禁用,當我點擊離開復選框,在表格行,複選框被選中。
解決這個問題的最佳方法是什麼? 也使行錶停用?
<table st-safe-src="sampleOverview.dataSet" st-table="sampleOverview.displayed" class="table table-striped">
<tr ng-repeat="sample in sampleOverview.displayed track by $index" ng-click="sample.selected = !sample.selected" ng-class="{success: sample.selected, warning : sample.deviceId == null || sample.methodId == null }" ng-disabled="sample.deviceId == null || sample.methodId == null">
<td class="hidden-xs hidden-sm">{{sample.lab}}</td>
<td class="hidden-xs hidden-sm">{{sample.subLab}}</td>
<td>{{sample.deviceLimsCode}}</td>
<td>{{sample.methodLimsCode}}</td>
<td>{{sample.sampleCode}}</td>
<td class="text-center hidden-xs hidden-sm">
<input type="checkbox" ng-model="sample.selected" ng-click="sampleOverview.selectSample($event, sample)" ng-disabled="sample.deviceId == null || sample.methodId == null">
</td>
</tr>
</tbody>
</table>
嘿Vivz,謝謝答覆。有沒有辦法保持ng-click並阻止傳播?我試過ng-click =「sample.selected =!sample.selected; $ event.stopPropagation();」它沒有工作 – ErEcTuS
爲什麼你需要ng-model的複選框與在ng-click中一樣,爲什麼你要切換它們 – Vivz
嗨,Vivz。感謝回覆。我需要這個,因爲當我切換到移動視圖時,我的複選框沒有出現。 ng-click使移動視圖處於可選狀態 – ErEcTuS