复选框无法在uib-accordion的标题中工作

时间:2016-12-13 08:32:13

标签: angularjs angular-ui-bootstrap

如果我在uib-accordion的标题中放置复选框,则不会检查

<uib-accordion>
  <div uib-accordion-group class="panel-default"
    is-open="daily"
    is-disabled="false">
    <uib-accordion-heading>
      <div class="checkbox">
        <label>
          <input type="checkbox" ng-model="daily">
          Daily
        </label>
      </div>
    </uib-accordion-heading>
    This content is straight in the template.
  </div>
</uib-accordion>

3 个答案:

答案 0 :(得分:1)

尝试

<input type="checkbox" checked="somevalue" ng-model="daily">

您可以输入alos ng-true-value和ng-false-value

答案 1 :(得分:1)

手风琴正在捕捉复选框点击事件,当您点击复选框时,您将需要停止将事件传播到手风琴

HTML

<input type="checkbox" ng-click="preventCheck($event)" ng-model="daily">

JS

$scope.preventCheck = function(e) {
  e.stopPropagation();
}

如果你想要

,你甚至可以内联它
ng-click="$event.stopPropagation();"

答案 2 :(得分:0)

尝试使用uib-btn-checkbox指令。这将在点击时切换您的绑定模型。

使用ng-click =“$ event.stopPropagation()”来阻止点击事件冒泡

<input type="checkbox" uib-btn-checkbox ng-model="daily" ng-click="$event.stopPropagation()">