Front-end Code
1 <ulclass= "List Checkstyle">2 <Liclass= "Item Item-checkbox">3 <labelclass= "checkbox checkbox-balanced">4 <inputtype= "checkbox"Ng-model= "Master"Ng-click= "All (Master,tesarry)">5 </label>6 Select All7 </Li>8 <Liclass= "Item Item-checkbox"ng-repeat= "Z in Tesarry">9 <labelclass= "checkbox checkbox-balanced">Ten <inputID={{z.userid}}type= "checkbox"Ng-model= "X"ng-checked= "Master"Ng-click= "Chk (z,x)"> One </label> A <imgsrc="#" /> - <H2>{{Z.name}}</H2> - </Li> the </ul>
Back-end Code
$scope. chosearr=[];//defines the array to hold the front-end display varStr= "";// varFlag= ";//if you clicked Select All, yes for a$scope. x=false;//not selected by default$scope. All=function(C,V) {//Select All if(c==true) {$scope. x=true; $scope. Chosearr=v; }Else{$scope. x=false; $scope. Chosearr=[]; } Flag= ' A '; }; $scope. CHK=function(z,x) {//single or multiple selection if(flag== ' a ') {//operate on a full selection basisstr = $scope. Chosearr.join (', ') + ', '; } if(x = =true) {//selectedstr = str + z.userid + ', '; } Else{str= str.replace (Z.userid + ', ', ');//uncheck} $scope. Chosearr= (Str.substr (0, Str.length-1)). Split (', '); }; $scope.Delete=function() {//Operation Curd if($scope. chosearr[0]== "" | | $scope. chosearr.length==0) {//prompt when no one is selectedAlert ("Please select at least one piece of data in action!") ") return; }; for(vari=0;i< $scope. chosearr.length;i++){ //alert ($scope. chosearr[i]);Console.log ($scope. chosearr[i]);//traverse the selected ID } };
Angular JS Implementation multi-Select all