Angular PHP批量删除



:最后我自己做了。所以这是溶液需要(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 ?我有一个用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>	

相关内容

  • 没有找到相关文章

最新更新