Angularjs angular复选框是否可以使用ng模型发布布尔值,而不是字符串?

Angularjs angular复选框是否可以使用ng模型发布布尔值,而不是字符串?,angularjs,checkbox,angular-ngmodel,Angularjs,Checkbox,Angular Ngmodel,如果选中,以下代码将提供支持\u enable='true',如果未选中,则为null <form> <input type="checkbox" name="support_enable" ng-value="config.support_enable" ng-model="config.support_enable"> </form> 我想知道有没有办法发布布尔值?在复选框插入隐藏字段之前,只需使用旧方法 <form> <input

如果选中,以下代码将提供
支持\u enable='true'
,如果未选中,则为null

<form>
  <input type="checkbox" name="support_enable" ng-value="config.support_enable" ng-model="config.support_enable">
</form>

我想知道有没有办法发布布尔值?

在复选框插入隐藏字段之前,只需使用旧方法

<form>
<input type="hidden" name="support_enable" ng-value="config.support_enable" ng-model="config.support_enable">
<input type="checkbox" name="support_enable" ng-model="config.support_enable">
</form>

尝试调用
ng change
上的函数,并根据获取的值更新变量值boolean

//在控制器中
$scope.checkValue=函数(值){
如果(值=='on'){
config.support\u enable=true;
}
其他的
config.support\u enable=false;
}


表单始终发送最后一个元素,因此如果选中复选框-它是复选框,如果不选中-它是隐藏字段。我想发布一个布尔值,发布只是一个字符串。config.support\u enable-将布尔值放在此处,它将发布一个“开”字符串
<form>
<input type="hidden" name="support_enable" ng-value="config.support_enable" ng-model="config.support_enable">
<input type="checkbox" name="support_enable" ng-model="config.support_enable">
</form>