jeudi 4 août 2016

How to check or unCheck the "Select ALL" check box, if any one of the other check boxes are checked or unchecked

Operation No 1: I have one super check box label as "Select ALL", and 10 other check boxes. if the Select All check box is check , all other checkbox should be check. if Select ALL check box is unchecked the all other should be unchecked. This working fine

Operation No 2:

In case If all the check boxes are checked, if i uncheck any one check box, the Select ALL check box being unchecked. This working fine.

What I want is If 9 check boxes are check, only 10th and Select ALL are unchecked, When I check that 10th check box, the "Select ALL" check box is remaining unchecked state how to make it check if all other check boxes are checked.

Below image, when all check boxes are check.

if I uncheck any one among those 10 check boxes, "Select All" check box become Uncheck that's correct.

enter image description here

If I check the Action check box, all the check boxes are checked but "Select ALL" check box remains uncheck, it should be check because all the check boxes are checked.

enter image description here

I couldn't find how to do, if any one knows please help me.

My code is:

$scope.itemClicked = function($index){
  if($index == 0){
    for(var i=0; i<languagePreference.length; i++){
      languagePreference[i].checked = languagePreference[0].checked;
     }
   }else{
     languagePreference[0].checked = false;
    }
 };
<div class="list" ng-controller="LangPrefController">
     <ion-checkbox ng-repeat="item in languagePreference"
                   ng-model="item.checked"                  
                   ng-click="itemClicked($index)">
     </ion-checkbox>
</div>



Aucun commentaire:

Enregistrer un commentaire