mercredi 24 juin 2015

How can I check all boxes in a nested ng-repeat by clicking a button?

So what I need to do is get only all of the shown (using ng-show) students checkboxes checked by clicking a toggleAll() button at the top of the page.

Here is my code:

<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">

                ........

I tried using:

$scope.toggleAll = function () {
        for (var i = 0; i < $scope.course.students.length; i++) {
            ...
        }
    };

but length is undefined. Any help would be greatly appreciated!




Aucun commentaire:

Enregistrer un commentaire