根据值是否未定义,我在复选框中将ng-checked
设置为true时出现问题。例如,在以下代码中..
<input class="custom-checkbox form-control" id="{{ point.pointId }}-{{ value }}"
type="checkbox"
ng-true-value="'{{ value }}'"
ng-model="item.sections[inspectionSection.sectionShortName[point.pointId].value">
我正在尝试设置ng-checked
,方法是检查value
是否可以设置为多个值之一。
例如:
ng-checked={{ if(value !== undefined) }}
我似乎无法让它发挥作用。我在ng-checked
尝试的任何内容都会检查所有复选框或者没有。任何帮助非常感谢!
答案 0 :(得分:0)
我建议在这种情况下使用函数。
ng-checked="isNotUndefined(value)"
// in the controller
isUndefined (value) {
return value !== undefined
}
答案 1 :(得分:-1)
您可以使用三元运算符来完成此操作:
ng-checked="value !== undefined ? true : false"