1
div class ="col-lg-5 stylethistitle"> 
<input type=" checkbox" ng-model = "checkedStatus">Show Deactivated Account</div> 

我需要在我的json请求中将$ scope.checkedStatus传递为false,当它被选中时为false,并且在未选中时为true。处理角js中的复选框

我需要显示停用的帐户。

包括我的JS下面

JS:

$scope.checkedStatus = true; 

$scope.viewAccount = function(){ 

       var json = { 
     "json": { 
    "request": { 
     "servicetype": "6", 
     "functiontype": "6014", 
     "session_id": $rootScope.currentSession, 
      "data": { 
     "shortname": $scope.model.selectShortName, 
     "groupzname": $scope.model.selectGname, 
     "city": $scope.model.selectCity, 
     "state": $scope.model.selectState, 
     "country": $scope.model.selectCountry, 
     "groupzcode": $scope.model.selectGcode, 
     "activationstatus": $scope.checkedStatus, 
     "details": false, 
     "sortbasedon": $scope.groupzname, 
     "offset":$scope.pagination 
      } 

    } 
    } 
}; 
         $scope.sortkey=''; 
         $scope.reverse=false; 

       UserService.viewListAccount(json).then(function(response) { 

       if (response.json.response.statuscode == 0 && response.json.response.statusmessage == 'Success') 
         { 
        $scope.tableData = response.json.response.data; 

         } 

      }); 
     }; 

回答

0

控制器指定为$ scope.checkedStatus的默认值。将其设置为true或初始值。

检查文档here

+0

我这样做,问题是将它们设置为false时,选择对我来说是真正的挑战。 –

+0

@NicoletaWilskon在传递它时会采取相反的值。 !($ scope.checkedStatus)会做这件事 –

0

需要设置$scope.checkedStatus默认为false。然后在你的json中使用它 -

"activationstatus":!($scope.checkedStatus) 
+0

如何使它们在检查时为假? –

+0

@NicoletaWilskon!($ scope.checkedStatus)将自动取消checkedStatus变量的值。你不需要做任何特别的事情 –

+0

我明白这一点。但是,如果未选中,我可以使用它,如果我让它们检查,如何更改我在我的json请求中传递的值。 –