如何在angularjs中选中复选框

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

我正在做angular is和spring引导程序,我想将我的复选框数据作为输入发送,但我遇到了错误。请看一下。

  1. 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.
  2. Here is the Angular-js code
  3. ---------------------------
  4. **$scope.saveUser = function() {
  5. $scope.locationArray=[];
  6. angular.forEach($scope.locations,function(location){
  7. <!-- alert(JSON.stringify(locations)) -->
  8. if(!!location.isselected)$scope.locationArray.push(location);
  9. });
  10. alert(JSON.stringify($scope.locationArray));
  11. alert("Your Data is Submiting ! Are You Sure to Submit ?..")
  12. $http.post("http://localhost:8765/user-api/user/saveAll",$scope.user).then(
  13. function successCallback(response) {
  14. console.log("User Successfully posted data");
  15. },
  16. function errorCallback(response) {
  17. console.log("Your Form Submission is failed");
  18. }
  19. );
  20. };**
  21. ---------------------------
  22. Here is the HTML Code
  23. ------------------------
  24. <div class="form-group" >
  25. Location::
  26. <div ng-repeat="location in locations">
  27. <label>{{location.opreaterAreaName}}</label>
  28. <input type="checkbox" class="form-check-input" ng-model ="location.isselected">
  29. </div>
goqiplq2

goqiplq21#

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

相关问题