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請求中傳遞的值。 –