mercredi 4 octobre 2017

How to get one or more data when we do click in checkbox?

I have a problem , when i do click on one or select all , all data coming. But i need when I click on single checkbox then only that particular data should come.

html file

<div class="row">
            <div class="col-md-12">
                <h1>Student Information</h1>
                <table id="example" class="table">
                    <tr>
                        <th>Name</th>
                        <th>Mobile</th>
                        <th>Siblling</th>
                        <th>select all <input type="checkbox" ng-click="vm.selectAll()"/></th>
                    </tr>
                    <tr ng-repeat="data in vm.data">
                        <td></td>
                        <td></td>
                        <td></td>
                        <td><input type="checkbox" ng-model="data.selected" class="duplicateRow" /></td>
                    </tr>
                    <tr>
                    <tr>

                    <button class="button pull-right"  ng-click="vm.process()">Process</button>
                    </tr>
                </table>
                    <table class="table">
                        <tr>
                            <td colspan="4">
                                <pagination ng-if="renderpagination" page-number='' page-count="" total-records="" api-url="duplicate-student"></pagination>
                            </td>
                        </tr>
                    </table>
           </div>
        </div>

Java script file

vm.selectAll =function(){
      angular.forEach(vm.data, function(data){
       data.selected=true;
      });
    }
    vm.selectedUsers = [];

    vm.process = function() {
      vm.selectedUsers.splice(0, vm.selectedUsers.length);
      for (var i in vm.data) {
           vm.selectedUsers.push(vm.data[i]);
      }
       $scope.uncheckAll = function() {
    $scope.selectedUsers.splice(0, $scope.selectedUsers.length);
}




Aucun commentaire:

Enregistrer un commentaire