【问题标题】:How to Get selected checkbox in angularjs如何在angularjs中获取选中的复选框
【发布时间】:2021-09-11 16:59:42
【问题描述】:

我正在执行 angular-is 和 Spring 启动程序,我想将复选框数据作为输入发送,但出现错误。请看一次。

I am doing angularjs and Spring boot program where i want to send my checkbox data as a input but i am getting error. please look once.

Here is the Angular-js code
---------------------------
**$scope.saveUser = function() {
$scope.locationArray=[];
angular.forEach($scope.locations,function(location){
<!--        alert(JSON.stringify(locations))        -->
if(!!location.isselected)$scope.locationArray.push(location);
});
alert(JSON.stringify($scope.locationArray));   
alert("Your Data is Submiting ! Are You Sure to Submit ?..")
$http.post("http://localhost:8765/user-api/user/saveAll",$scope.user).then(
function successCallback(response) {
console.log("User Successfully posted data");
},
function errorCallback(response) {
console.log("Your Form Submission is  failed");
}
);
};**
---------------------------

Here is the HTML Code
------------------------
<div class="form-group" >
Location:: 
<div ng-repeat="location in locations"> 
   <label>{{location.opreaterAreaName}}</label>
   <input type="checkbox"   class="form-check-input"  ng-model ="location.isselected">
</div>

【问题讨论】:

  • 你的错误在哪里?
  • 请添加正确的功能代码以及错误也
  • 我想使用复选框发送数据,但它说的是 Null 值。数据没有从网页传递到函数。我认为每当在推送中存在一些问题......并且功能和html代码已经存在,请看一次并帮助我。谢谢

标签: javascript java angularjs spring-boot microservices


【解决方案1】:

添加后。问题解决了

$scope.user.locations=$scope.locationArray;

【讨论】:

    猜你喜欢
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-01
    • 2014-02-20
    • 1970-01-01
    • 2015-02-12
    相关资源
    最近更新 更多