[英]Get the value of the checked checkbox in angularjs
I am currently developing a web app. 我目前正在开发一个Web应用程序。 I have 10 checkboxes inside my form.
我的表单中有10个复选框。
How can I grab the values of the currently selected checkboxes? 如何获取当前选定复选框的值?
<input type="checkbox" value="Wifi" name="wifi"><i class="fa fa-wifi fa-lg"></i> Wifi Internet
<input type="checkbox" value="kitchen" name="kitchen"><i class="fa fa-cutlery fa-lg"></i> Kitchen
....
You need to add ng-model
s . 您需要添加
ng-model
。
<input ng-model="wifi" type="checkbox" value="Wifi" name="wifi">
<input ng-model="kitchen" type="checkbox" value="kitchen" name="kitchen">
..etc
Then in your controller: 然后在您的控制器中:
$scope.wifi // true or false
$scope.kitchen // true or false
Once you have these values in your controller, you can send the checkbox data to a server to do with as it wishes. 一旦在控制器中拥有了这些值,就可以将复选框数据发送到服务器以根据需要进行处理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.