$scope.selectIds=[];//选中的id集合
//向集合添加复选框中ID
$scope.updateSelection=function ($event,id) {
if ($event.target.checked) {
$scope.selectIds.push(id);//向集合添加元素
}else{
var index=$scope.selectIds.indexOf(id);//获取值得角标
$scope.selectIds.splice(index,1);//参数1,移除的位置;参数2,移除的个数
}
}
$event.target代表当前的input
$event:用js原生api+angularjs添加和移除数组元素
最新推荐文章于 2021-02-25 09:00:59 发布