【发布时间】:2015-06-17 23:27:53
【问题描述】:
我想实现全选复选框(用于多次删除)。
这是我的视图脚本:
<input type="checkbox" name="chk_all" id="chk_all" ng-click="checkAll(this)" /> Select All
<table>
<tr ng-repeat="user in allUsers">
<td><input type="checkbox" ng-model="list" name="list[]" class="chk_all" value="{{user.user_id}}" id="{{user.user_id}}" ng-checked="checkedAll" /></td>
<td>{{user.username}}</td>
<td>{{user.fname}}</td>
<td>{{user.lname}}</td>
<td>{{user.mobile}}</td>
<td>{{user.email}}</td>
<td><a title="Edit User" href="#/edit_user/{{user.user_id}}" ><span class="fa fa-pencil"></span></a> | <a title="Delete User" id="" style="cursor:pointer;" ng-click="delete_user(user.user_id)" ><span class="fa fa-trash-o"></span></a></td>
</tr>
</table>
在"chk_all" 复选框后面的所有复选框应选中或取消选中。
我想在单击按钮时删除选定的用户。那么如何在 http post 方法中获取选定的用户 ID。
脚本写成:
$scope.testFunction=function(params)
{
$http.post("../admin/users/testFunction",{'params' : params})
.success(function (data, status, headers, config)
{
console.log(data);
alert(1);
})
.error(function(data, status, headers, config){
});
}
控制器功能:
public function testFunction()
{
$data = json_decode(file_get_contents("php://input"));
print($data->params);
}
在 testFunction(php 函数)中,我如何检索选定的用户 ID? 有什么解决办法吗? 注意:我已经用 javascript 和 php 完成了。现在应用程序要转换成 Angularjs,所以它应该在 angularjs 中。
【问题讨论】:
标签: angularjs