默认情况下,手动选中一个复选框,根据选中的复选框存储0,1商店,根据复查'0','1'选中复选框

时间:2017-04-22 08:16:52

标签: angularjs

<input type="text" class="form-control" placeholder="Service Number" id="service_num" name="service_num" ng-model="service_num" ng-blur="GetUfdreportdata()">
<span>Details</span>
<label>
    <input type="checkbox" class="detailcheckbok" id="deatilsmanual_0" name="deatailsmanual" ng-model="deatilsmanual_0" value="0" checked/> Manual </label>
<label>
    <input type="checkbox" class="detailcheckbok" id="deatilsmanual_1" name="deatailsmanual" ng-model="deatilsmanual_1" value="1" /> Auto </label>
<input type="button" value="Submit" ng-click="myfunction()" />


app.controller("cap", function($scope, $http, $mdDialog) {

    $scope.myfunction = function() {

        $http.post("save_report.php", {


            }
        }

        $scope.GetUfdreportdata = function() {

            $http({
                method: "GET",
                url: "api/api.php",
                params: {
                    service_num: $scope.service_num
                }
            }).success(function(data) {}


            });

1 个答案:

答案 0 :(得分:0)

尝试使用以下代码根据复选框行为存储0,1值。

<script>
  angular.module('checkboxExample', [])
    .controller('ExampleController', ['$scope', function($scope) {
      $scope.checkboxModel = {  value1 : 1, value2 : 1 };
    }]);
</script>
<form name="myForm" ng-controller="ExampleController">
  <label>Value1:
    <input type="checkbox" ng-model="checkboxModel.value1" 
    ng-true-value="1" ng-false-value="0">
  </label><br/>
  <label>Value2:
    <input type="checkbox" ng-model="checkboxModel.value2"
           ng-true-value="1" ng-false-value="0">
   </label><br/>
  <tt>value1 = {{checkboxModel.value1}}</tt><br/>
  <tt>value2 = {{checkboxModel.value2}}</tt><br/>
 </form>