When you have a checkbox, not necessary that just 'ture' & 'false', you might have 'yes', 'no', '1', '0':

There is how to use ng-true-value and ng-false-value with ng-checked for checkbox:

<input type="checkbox" 
    ng-model="checkbox" 
    ng-true-value="1" 
    ng-false-value="0" 
    ng-checked="checkbox == 1" />
$scope.$watch(function(){
    return $scope.checkbox;
}, function(){
    $scope.checkbox = Number($scope.checkbox);
    console.log($scope.checkbox, typeof $scope.checkbox);
},true);

 

相关文章:

  • 2021-07-22
  • 2022-12-23
  • 2021-08-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
  • 2021-10-19
  • 2022-02-08
  • 2021-08-22
相关资源
相似解决方案