$event:用js原生api+angularjs添加和移除数组元素

		$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

猜你喜欢

转载自blog.csdn.net/Bird_King/article/details/92796401