【问题标题】:Angularjs checklist-model - disable unchecked boxesAngularjs 清单模型 - 禁用未选中的框
【发布时间】:2015-08-13 01:18:07
【问题描述】:

嘿,Stackoverflow 的超级英雄们。我目前正在使用 angularjs 和 checklist-model 指令处理清单。我试图弄清楚当达到 x 数量的复选框时如何禁用所有未选中的框。

我正在从 json 文件中获取数据,因此我的复选框位于 ng-repeat 中。

现在我禁用所有复选框。当达到检查的 x 数时。不幸的是,用户应该能够更改已选择的内容。

<label ng-repeat="item in items | orderBy:item_position"> 
<h3>{{item.item_name}}</h3>
<p>{{item.item_position}}</p>
<!--checkbox -->
<input type="checkbox" ng-disabled="item.answers.length >= 12" checklist-model="item.answers" checklist-value="player">

【问题讨论】:

    标签: javascript angularjs checkbox


    【解决方案1】:

    您可以在您的 ng-disabled 中尝试一下:

    ng-disabled="item.answers.length &gt;= 12 &amp;&amp; item.answers === player"

    但是,如果您发布了一个带有指令和一些示例数据的 jsfiddle,那将会很有用。

    【讨论】:

      【解决方案2】:

      在您的复选框输入上尝试此属性以执行所需的限制:

      ng-disabled="!checked && item.answers.length >= 12"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-01-11
        • 1970-01-01
        • 2016-07-17
        • 1970-01-01
        • 1970-01-01
        • 2022-01-10
        • 1970-01-01
        相关资源
        最近更新 更多