Javascript 如何在使用angularjs提交后获取复选框值?

Javascript 如何在使用angularjs提交后获取复选框值?,javascript,jquery,angularjs,checkbox,Javascript,Jquery,Angularjs,Checkbox,我有一些提供的复选框列表,当我提交时必须获得复选框值。我已经尝试,但它不起作用,我已经在下面添加了我的代码。现在我获得了提供消息id,但提交后我没有获得复选框值,请帮我解决。 功能测试1控制器($scope){ var storeid=window.localStorage.getItem(“storeid”); var serverData=[“三星Galaxy Note”、“三星Galaxy S6”、“三星Galaxy Avant”、“三星Galaxy Young”]; $scope.i

我有一些提供的复选框列表,当我提交时必须获得复选框值。我已经尝试,但它不起作用,我已经在下面添加了我的代码。现在我获得了提供消息id,但提交后我没有获得复选框值,请帮我解决。

功能测试1控制器($scope){
var storeid=window.localStorage.getItem(“storeid”);
var serverData=[“三星Galaxy Note”、“三星Galaxy S6”、“三星Galaxy Avant”、“三星Galaxy Young”];
$scope.items=[];
$scope.selection=[];
$scope.offers=[{
id:“as23456”,
商店:“三星”,
报价信息:“1500卢比关闭”,
modalname:“三星Galaxy Young”
},{
id:“de34575”,
商店:“三星”,
提供信息:“在三星Galaxy S6上20%平坦”,
modalname:“三星Galaxy S6”
},]
$scope.toggleSelection=函数toggleSelection(项){
$scope.gotOffers=[];
var idx=$scope.selection.indexOf(项目);
//当前已选定
如果(idx>-1){
$scope.selection.splice(idx,1);
}
//是新选中的
否则{
$scope.selection.push(项目);
}

对于(var i=0;i而言,您似乎希望迭代
$scope.selection
,而不是
$scope.items

更改:

var checkedItems = [];$scope.selection
for (var i = 0; i < $scope.items.length; i++) {
  if ($scope.items[i].selected) {
    checkedItems.push($scope.items[i].name);
  }
}

您似乎希望迭代
$scope.selection
,而不是
$scope.items

更改:

var checkedItems = [];$scope.selection
for (var i = 0; i < $scope.items.length; i++) {
  if ($scope.items[i].selected) {
    checkedItems.push($scope.items[i].name);
  }
}

当我选择三星Galaxy S6时,下拉列表即将出现,并且我已选择了其工作。当我删除三星Galaxy S6时,下拉列表不会出现,但当我提交时,我将获得该报价id。当我选择三星Galaxy S6时,下拉列表即将出现,并且我已选择了其工作。当我删除三星Galaxy S6时,下拉列表不会出现,但当我提交我正在获得该报价id。
var checkedItems = $scope.selection.map(function(checkbox) {
  return checkbox.name;
});