我有一个通过 WebService 中的 ng-repeat 显示的凭证列表,每个凭证都有一个关联的复选框,当我选中特定复选框时,凭证的价格会从总价格中扣除,这是有问题的问题是:“一旦总价为 0,我必须禁用未选中的复选框”,此时我可以禁用所有复选框,但我想保持选中的复选框启用,以便我可以再次取消选中它们。
HTML:
<div class="item" ng-class="{active:!$index}" ng-repeat="slide in MesAvoirs | limitTo: slideLength track by $index">
<div class="mes_avoires" ng-repeat="a in MesAvoirs | startFrom: ($index*5) | limitTo: 5">
<input class="mes_avoires_checkbox" type="checkbox" ng-model="check" ng-change="avoirPrixCal($index,check,a)" id="chBx-{{$index}}" ng-disabled="uncheckVar" />
<div class="left_av">
<em>{{"MonProfilMesAvoirs.Num_Avoir" | translate}} {{a.NumeroAvoir}}</em>
<strong>{{a.Montant}} {{"Globale.Devise" | translate}}</strong>
</div>
<div class="right_av">
<em translate="MonProfilMesAvoirs.Valide_till"></em>
<strong>{{a.DateValiditeJ }} {{a.DateValiditeM}} {{a.DateValiditeY}}</strong>
</div>
</div>
</div>
最佳答案
如果我理解您的问题,您希望在总价等于 0 时禁用未选中的复选框。
为什么不使用模型来获取复选框的状态(选中或未选中)并测试如下内容:
<input type="checkbox" ng-model="yourCtrl.checked[your_checkbox_number]" ng-disable="(yourCtrl.totalPrice <= 0 && !yourCtrl.checked[your_checkbox_number])/>
关于javascript - AngularJS 禁用 ng-repeat 中未选中的复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37552382/