jeudi 16 avril 2015

Enable and disable check boxes using ng-disabled

I got a list of check box + labels. If you check the first one, all the checkbox (except the first one) have to be disabled. The problem is that if I uncheck the first checkbox, all the others are still disabled and I want them to be enable again.


JS



<li ng-repeat="ques in questions">
<input type="checkbox" ng-click="addRemove(ques)" ng-checked="contains(ques) != -1" ng-disabled="noneSelected && $index != 0"/> {{ques.question}}
</li>


controller



if (ques.question == "None") {
var index = $scope.contains(ques);
if (index != -1) {
$scope.noneSelected = false;
$rootScope.selectedQuestions.splice(index, 1);
} else {
$scope.noneSelected = true;
$rootScope.selectedQuestions = [];
$rootScope.selectedQuestions.push(ques);
}
}




Aucun commentaire:

Enregistrer un commentaire