【问题标题】:Include the check boxes before selected angular js在选定的 Angular js 之前包含复选框
【发布时间】:2015-07-02 23:25:38
【问题描述】:

如果选中一个,是否可以在列表中包含所有复选框。例如,页面上有 10 个复选框,我们选中第 5 个 - 所以应该选中 1,2,3,4,5。 有人有 Angular JS 的例子吗?

【问题讨论】:

  • 是的,有可能。尝试一些东西(提示:ngChange$scope.$watch)然后返回一些代码。
  • 可以在 google 搜索中找到示例...这个网站不是 google

标签: angularjs checkbox input


【解决方案1】:

正如 Blackhole 所指出的,一个可能的解决方案是在您的复选框上使用 ng-change。

你的html:

<input type="checkbox" ng-repeat="bx in boxes" ng-model="bx.value" ng-change="boxChecked($index, bx.value)">

在控制器中:

$scope.boxChecked = function(index, value) {
  for (var i = 0; i < index; i++) {
    $scope.boxes[i].value = value;
  }
}

【讨论】:

    猜你喜欢
    • 2015-11-25
    • 2015-04-11
    • 2021-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-30
    • 2013-08-08
    • 2016-07-03
    相关资源
    最近更新 更多