这是我的观点,我想获取诸如diadia或htn等值,因为我想以字符串格式存储它们。但是我现在以一种对象格式获取它的方式
font(color ='green', size ='3')
strong Past History
.checkbox
label
input(type='checkbox', value='',name = 'diabetes', ng-model = 'formData.history.diabetes')
| DIABETES
.checkbox
label
input(type='checkbox', value='',name = 'htn', ng-model = 'formData.history.htn')
| HTN
.checkbox
label
input(type='checkbox', value='',name = 'asthma', ng-model = 'formData.history.asthma')
| ASTHMA/COPD
现在在我的控制器中,当我
console.log($scope.formData.history)
我得到这样的输出:
`{diabetes : true}`
但是我想以String形式将此数据发送到我的后端。任何想法如何只获得“糖尿病”或“ htn”。谢谢你
默认情况下,绑定到复选框模型的值的类型为布尔值。这就是为什么您获得价值true
或false
作为价值的原因。
使用指令ng-true-value
和/或ng-false-value
如果要更改它。这是html的示例:
<input type="checkbox" name="htn" ng-model="formData.history.htn" ng-true-value="'htn'">
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句