点击input,checkbox,先判断再赋值是选中否

点击input checkbox,复选框先判断再决定选中否,可以用event.preventDefault(); 阻止默认事件,再手动赋值;

angular 阻止checkbox默认事件,

<label>
   <input type="checkbox" ng-click="changeState($event)" ng-checked="checkState">                        
</label>

//js
$scope.checkState = false;

$scope.testVal = 1;

$scope.changeState = function($event){
     
	$event.preventDefault();
	if($scope.testVal == 1){
     
		$scope.checkState = true;
	}else{
     
		$scope.checkState = false;
	}
}

你可能感兴趣的:(js,angularjs,checkbox阻止默认,checkbox)