【发布时间】:2015-09-11 03:08:59
【问题描述】:
所以我需要做的是通过单击页面顶部的 toggleAll() 按钮,仅选中所有显示的(使用 ng-show)学生复选框。
这是我的代码:
<div ng-repeat="course in content" ng-show="course.show" >
<div ng-repeat="student in course.students" ng-show="student.show" ng-click="toggleStudent(student)">
<input type="checkbox">
........
我尝试使用:
$scope.toggleAll = function () {
for (var i = 0; i < $scope.course.students.length; i++) {
...
}
};
但长度未定义。 任何帮助将不胜感激!
【问题讨论】:
-
请提供一个 JSFiddle 机智大厅的代码?这有助于我们更快/更轻松地进行调试。
-
全部切换按钮在哪里?
-
另见this related question(带有主复选框,而不仅仅是一个按钮)。
标签: javascript html angularjs checkbox