如何在angularjs中选中复选框

fd3cxomn  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(262)

我正在做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>
goqiplq2

goqiplq21#

加上这个之后。问题解决
$scope.user.locations=$scope.locationarray;

相关问题