即使ng-disabled为复选框,也会触发ng-click

时间:2017-08-08 16:49:08

标签: javascript angularjs

即使ng-disabled为true,也会触发

ng-click。 如何防止这种情况发生。

<div class="fila">
  <div class="seccion">
    <div class="asiento">
       <input ng-checked="seatLayout[0].reserved " ng-disabled="seatLayout[0].reserved || result.length == parseInt(maxSeats) "
type="checkbox" value="None" id="asiento1" name="check"/>
       <label ng-class="{'selected' : seatLayout[0].reserved == true, 'notselected' : seatLayout[0].reserved == false}"
ng-click="addSeat(seatLayout[0])"
for="asiento1">{{seatLayout[0].id}}</label>
    </div>
  </div>
</div>

1 个答案:

答案 0 :(得分:0)

您可以将ng-disabled条件添加到ng-click,如下所示:

ng-click="(seatLayout[0].reserved || result.length == parseInt(maxSeats) ) || addSeat(seatLayout[0])"

这将阻止条件为真时单击标签。