1
[Решение]: Наконец, я сделал это сам. так вот решение он принимает (7 часов).угловой php bulk delete
//Solution angularjs
$scope.exampleArray = [];
\t \t $scope.pushInArray = function(id) {
\t // get the input value
\t var inputVal = id;
\t var array = $scope.exampleArray.push(inputVal);
\t \t $scope.deleteBulk = function(){
\t \t \t if(confirm("Are you sure you want to delete this record?")){
\t \t \t \t $http.post('http://localhost/angular-code-crud/index.php/user/bulk_delete_user',
\t \t {'id':$scope.exampleArray}).success(function(){
\t \t \t $scope.displayUsers();
\t \t });
\t \t }
\t }; \t
\t };
<!-- Solution HTML -->
<button class="btn btn-danger" ng-click="deleteBulk()" >Delete</button>
<table class="table table-striped">
\t <thead>
\t \t <tr>
\t \t \t <th><input type="checkbox" ng-model="master" ></th>
\t \t \t <th>Name</th>
\t \t \t <th>Gender</th>
\t \t \t <th>Email</th>
\t \t \t <th>Address</th>
\t \t \t <th>Phone</th>
\t \t \t <th>Action</th>
\t \t </tr>
\t </thead>
\t <tbody>
\t \t
\t </tbody>
\t <tr ng-repeat="user in users | filter:searchUser">
\t \t <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 }} -->
\t \t \t
\t \t <input type="checkbox" name="arrExample" ng-model="arrInput" ng-true-value="{{user.id}}" ng-checked="master"ng-click='pushInArray(user.id)'><br>
\t \t </td>
\t \t <td>{{ user.name }}</td>
\t \t <td>{{ user.gender }}</td>
\t \t <td>{{ user.email }}</td>
\t \t <td>{{ user.address }}</td>
\t \t <td>{{ user.phone }}</td>
\t \t <td>
\t \t <button class="btn btn-primary" ng-click="updateData(user.id, user.name, user.gender, user.email, user.address, user.phone)">Edit</button>
\t \t <button class="btn btn-danger" ng-click="deleteData(user.id)">Delete</button>
\t \t </td>
\t </tr>
\t </table> \t \t
Как я могу получить идентификаторы флажком с помощью angularjs? У меня есть таблица с использованием угловых символов. но не знаю, как я передаю идентификаторы каждой строки, которую я проверил, используя флажок.
$scope.deleteBulk = function($scope){
\t \t //what code should i use to get ids of checked row
\t }
<button ng-click="deleteBulk()">Delete</button>
<table class="table table-striped">
\t <thead>
\t \t <tr>
\t \t \t <th>select</th>
\t \t \t <th>Name</th>
\t \t \t <th>Gender</th>
\t \t \t <th>Email</th>
\t \t \t <th>Address</th>
\t \t \t <th>Phone</th>
\t \t \t <th>Action</th>
\t \t </tr>
\t </thead>
\t <tbody>
\t \t
\t </tbody>
\t <tr ng-repeat="user in users | filter:searchUser">
\t \t <td><input type="checkbox" checklist-model="user.roles(user.id)" checklist-value="user.id">{{ user.id }}</td>
\t \t <td>{{ user.name }}</td>
\t \t <td>{{ user.gender }}</td>
\t \t <td>{{ user.email }}</td>
\t \t <td>{{ user.address }}</td>
\t \t <td>{{ user.phone }}</td>
\t \t <td>
\t \t <button class="btn btn-primary" ng-click="updateData(user.id, user.name, user.gender, user.email, user.address, user.phone)">Edit</button>
\t \t <button class="btn btn-danger" ng-click="deleteData(user.id)">Delete</button>
\t \t </td>
\t </tr>
\t </table> \t
Я невежественный. Извините за плохой английский,
Использование нг-клик = "user.roles (user.id)" будет лучше или нг-изменений. – Jigar7521
на кнопке или флажок? –