如何禁用整个表单,包括离子复选框

时间:2016-06-14 12:54:36

标签: angularjs ionic-framework

我有一个包含多个离子复选框的表单,我想让它只读。

基于this answer我在字段集中添加了一个布尔值。它适用于选择和文本框。但是离子复选框虽然看起来已禁用,但仍会触发点击事件并切换其状态

<form>
  <fieldset ng-disabled="myBooleanValue">
    <!-- selects and textboxes are all disabled as you'd expect-->
    <ion-checkbox ng-repeat="va in q.ValidAnswers | orderBy:'SortOrder'"
                  ng-click="vm.setAnswer(q.ID, va.AnswerID)"
                  ng-checked="vm.isChecked(currentAnswers, va.AnswerID)">
        {{va.Text}}
    </ion-checkbox>
   </fieldset>
</form>

1 个答案:

答案 0 :(得分:1)

select添加到ng-disabled

ion-checkbox

添加<ion-checkbox ng-disabled="myBooleanValue" ng-repeat="va in q.ValidAnswers | orderBy:'SortOrder'" ng-click="vm.setAnswer(q.ID, va.AnswerID)" ng-checked="vm.isChecked(currentAnswers, va.AnswerID)"> {{va.Text}} </ion-checkbox>

ng-click="myBooleanValue || ..."

小提琴:http://jsfiddle.net/1oub4yhg/2/

参考:ng-click still fires