Angular JS Implementation multi-Select all

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.