mercredi 20 mai 2015

Disable button based on checkbox selection

I'm having a list of check boxes and a main check box which if selected checks all the check boxes .I can also check the individual check boxes.

HTML:

<button type="button"  ng-disabled="!selectedAll">Click</button>

 <div>
    <input type="checkbox" ng-model="selectedAll" class="checkbox" ng- click="toggle=!toggle">
</div>    

<div ng- repeat="item in items" >
<input type="checkbox" ng- checked="toggle" ng-model="selectedCheckBox[item.id]"> <i></i>
</div>

Controller:

$scope.toggle = false;
$scope.selectedIntervention = {};

I'm able to disable/enable the button by selecting the main check box(outside ng-repeat) by enabling ng-disabled="!selectedAll" .But I'm not able to diable the button if I select any check box that is inside ng-repeat.I tried by giving ng-model="!selectedCheckBox" but didn't worked that way.Any possible solution is highly appreciated.Thanks

$scope.toggle = false;
$scope.selectedCheckBox = {};




Aucun commentaire:

Enregistrer un commentaire