no-repeat 循环生成的购物车,当选择或取消选择选项时通过服务提交到后台
找到这篇文章
http://blog.csdn.net/itfootball/article/details/51455839
html代码
<div ng-repeat="item in Carts.CartItemList" >
<input type="checkbox" ng-model="$parent.Carts.CartItemList[$index].Selected" ng-click="itemcheck($event)">
</div>
js代码:
var app = angular.module('cartApp', []);
app.controller('cartCtrl', function ($scope, CartService) {
$scope.Carts = {};
CartService.GetCart().then(function (json) {
view(json, $scope);
}).finally(function () {
loading.modal("hide");
});
$scope.itemcheck = function () {
loading.modal("show");
//传参 产品 pid和选择状态($scope.Carts.CartItemList[this.$index].Selected)
CartService.selectCart(this.item.PId, $scope.Carts.CartItemList[this.$index].Selected).then(function (json) {
view(json, $scope);
}).finally(function () {
loading.modal("hide");
});
}
});
重点是:
$scope.Carts.CartItemList[this.$index].Selected
这句可以找到对应的表单
json大致结构
{"TotalCount":3,"CartItemList":[{"PId":1,"Selected":false,...},{"PId":2,"Selected":true,...}]}