最近因为项目原因重新捡起来了AngularJS ,遇到老问题复选框选中和值的问题。
先贴以前网上找的解决方案
http://www.cnblogs.com/CheeseZH/p/4517701.html
个人感觉太麻烦了,代码太多,然后自己找了点资料,现在如下自己的解决方案
全选checkbox按钮
<input type="checkbox" ng-model="all"> <span>全选</span>
ng-repeat里面的checkbox按钮<form name="testFrom" action="">
<div ng-repeat="x in shoppingCartList" >
<input type="checkbox" ng-checked="all" value="{
{x.userId}}" name="userId" "></div>
</div>
</form name="testFrom">
获取值的方法
$scope.deleteUserProduct = function(){
$scope.userIdList= ''; //先赋值 '' 避免append的时候 undefined
var formEle = document.testFrom.elements.userId; //获取form表单name等于userId元素