Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用angularJS从html中的多个复选框中检索值_Html_Angularjs_Checkbox - Fatal编程技术网

使用angularJS从html中的多个复选框中检索值

使用angularJS从html中的多个复选框中检索值,html,angularjs,checkbox,Html,Angularjs,Checkbox,我有一个场景,其中必须在设备上配置任何一个协议。web UI将所有选项显示为复选框,我需要检索已选中的协议和设备,并通过http post将此数据发送到后端服务器。我正在使用HTML和AngularJS。 下面是我迄今为止的代码,请建议是否可以以更好的方式完成 var Myapp=angular.module('Myapp',[]); Myapp.controller('CloudController',函数($scope,$http) { $scope.execute=函数(ImageLoc

我有一个场景,其中必须在设备上配置任何一个协议。web UI将所有选项显示为复选框,我需要检索已选中的协议和设备,并通过http post将此数据发送到后端服务器。我正在使用HTML和AngularJS。 下面是我迄今为止的代码,请建议是否可以以更好的方式完成

var Myapp=angular.module('Myapp',[]);
Myapp.controller('CloudController',函数($scope,$http)
{
$scope.execute=函数(ImageLoc、协议、设备)
{
#HTTP请求将在此处生成
};
});

选择协议:
L3健全性
L2健全性
路由选择
STP
VLAN
接口规模
VLAN规模
选择设备: DUT 1
DUT 2
DUT 3
DUT 4
DUT 5
输入图像位置:


我知道如何生成http请求。我只需要知道如何检索选中的选项。创建isSelected属性并将其附加到每个项。遍历项目列表并检查isSelected是否为true。这可能会对您有所帮助:在这种情况下,您需要使用
select
元素not multiple复选框。因为您只需要选择一个选项,而不需要选择多个。如果必须使用复选框,则需要使用
ngChange
处理模型。