angular php 批量删除

angular php bulk delete

[解决方法]:最后还是自己搞定了。所以这是解决方案(7 小时。)

//Solution angularjs
$scope.exampleArray = [];
   $scope.pushInArray = function(id) {
  // get the input value
  var inputVal = id;
  var array = $scope.exampleArray.push(inputVal);
   $scope.deleteBulk = function(){
    if(confirm("Are you sure you want to delete this record?")){
     $http.post('http://localhost/angular-code-crud/index.php/user/bulk_delete_user',
          {'id':$scope.exampleArray}).success(function(){
              $scope.displayUsers();
          });
       }
     };  
  };
<!-- Solution HTML -->
<button class="btn btn-danger" ng-click="deleteBulk()" >Delete</button>
<table class="table table-striped">
 <thead>
  <tr>
   <th><input type="checkbox" ng-model="master" ></th>
   <th>Name</th>
   <th>Gender</th>
   <th>Email</th>
   <th>Address</th>
   <th>Phone</th>
   <th>Action</th>
  </tr>
 </thead>
 <tbody>
  
 </tbody>
 <tr ng-repeat="user in users | filter:searchUser">
  <td><!-- <input type="checkbox" ng-click="deleteBulk(user.id)" ng-true-value="{{user.id}}" ng-checked="master" checklist-model="user.id" checklist-value="{{user.id}}">{{ user.id }} -->
   
  <input type="checkbox" name="arrExample" ng-model="arrInput" ng-true-value="{{user.id}}" ng-checked="master"ng-click='pushInArray(user.id)'><br>

  </td>
  <td>{{ user.name }}</td>
  <td>{{ user.gender }}</td>
  <td>{{ user.email }}</td>
  <td>{{ user.address }}</td>
  <td>{{ user.phone }}</td>
  <td>
   <button class="btn btn-primary" ng-click="updateData(user.id, user.name, user.gender, user.email, user.address, user.phone)">Edit</button>
  <button class="btn btn-danger" ng-click="deleteData(user.id)">Delete</button>
  </td>
 </tr>
 </table>  

如何使用 angularjs 获取所选复选框的 ID? 我有一个 table 使用 angularjs 获取。但不知道我如何传输我使用复选框选中的每一行的 ID。

$scope.deleteBulk = function($scope){
  //what code should i use to get ids of checked row
 }
<button ng-click="deleteBulk()">Delete</button>
<table class="table table-striped">
 <thead>
  <tr>
   <th>select</th>
   <th>Name</th>
   <th>Gender</th>
   <th>Email</th>
   <th>Address</th>
   <th>Phone</th>
   <th>Action</th>
  </tr>
 </thead>
 <tbody>
  
 </tbody>
 <tr ng-repeat="user in users | filter:searchUser">
  <td><input type="checkbox" checklist-model="user.roles(user.id)" checklist-value="user.id">{{ user.id }}</td>
  <td>{{ user.name }}</td>
  <td>{{ user.gender }}</td>
  <td>{{ user.email }}</td>
  <td>{{ user.address }}</td>
  <td>{{ user.phone }}</td>
  <td>
   <button class="btn btn-primary" ng-click="updateData(user.id, user.name, user.gender, user.email, user.address, user.phone)">Edit</button>
  <button class="btn btn-danger" ng-click="deleteData(user.id)">Delete</button>
  </td>
 </tr>
 </table> 

我一无所知。抱歉英语不好,

//Solution angularjs
$scope.exampleArray = [];
   $scope.pushInArray = function(id) {
  // get the input value
  var inputVal = id;
  var array = $scope.exampleArray.push(inputVal);
   $scope.deleteBulk = function(){
    if(confirm("Are you sure you want to delete this record?")){
     $http.post('http://localhost/angular-code-crud/index.php/user/bulk_delete_user',
          {'id':$scope.exampleArray}).success(function(){
              $scope.displayUsers();
          });
       }
     };  
  };
<!-- Solution HTML -->
<button class="btn btn-danger" ng-click="deleteBulk()" >Delete</button>
<table class="table table-striped">
 <thead>
  <tr>
   <th><input type="checkbox" ng-model="master" ></th>
   <th>Name</th>
   <th>Gender</th>
   <th>Email</th>
   <th>Address</th>
   <th>Phone</th>
   <th>Action</th>
  </tr>
 </thead>
 <tbody>
  
 </tbody>
 <tr ng-repeat="user in users | filter:searchUser">
  <td><!-- <input type="checkbox" ng-click="deleteBulk(user.id)" ng-true-value="{{user.id}}" ng-checked="master" checklist-model="user.id" checklist-value="{{user.id}}">{{ user.id }} -->
   
  <input type="checkbox" name="arrExample" ng-model="arrInput" ng-true-value="{{user.id}}" ng-checked="master"ng-click='pushInArray(user.id)'><br>

  </td>
  <td>{{ user.name }}</td>
  <td>{{ user.gender }}</td>
  <td>{{ user.email }}</td>
  <td>{{ user.address }}</td>
  <td>{{ user.phone }}</td>
  <td>
   <button class="btn btn-primary" ng-click="updateData(user.id, user.name, user.gender, user.email, user.address, user.phone)">Edit</button>
  <button class="btn btn-danger" ng-click="deleteData(user.id)">Delete</button>
  </td>
 </tr>
 </table>