我尝试用角度构造一个公式,但在选择元素中显示数据不起作用......
公式.cs.html:
<table style="display: inline-block; float: left; max-width: 510px;">
<tr data-ng-repeat="question in group.questions">
<td>{{question.name}}</td>
<td>
<div ng-switch on="question.control" style="display: inline-block;">
<div ng-switch-when="input">
<input type="text" style="width: {{ question.size }};" data-isnull="{{question.isnull}}" name="{{question.dbcolumn}}" id="{{question.dbcolumn}}" placeholder="{{question.default_value}}" maxlength="{{question.max_length}}" />
</div>
<div ng-switch-when="textarea">
<textarea style="width: {{ question.size }};" data-isnull="{{question.isnull}}" name="{{question.dbcolumn}}" id="{{question.dbcolumn}}" placeholder="{{question.default_value}}"></textarea>
</div>
<div ng-switch-when="checkbox">
<input type="checkbox" data-isnull="{{question.isnull}}" name="{{question.dbcolumn}}" id="{{question.dbcolumn}}" />{{question.default_value}}
</div>
//MY PROBLEM HERE !
<div ng-switch-when="select">
<select style="width: {{ question.size }};" data-isnull="{{question.isnull}}" name="{{question.dbcolumn}}" id="{{question.dbcolumn}}">
<option ng-repeat="choice in question.default_value" value="{{choice.value}}">{{choice.name}}</option>
</select>
<select style="width: {{ question.size }};" data-isnull="{{question.isnull}}" name="{{question.dbcolumn}}" id="{{question.dbcolumn}}" ng-model="question" ng-options="choice.value for choice in question.default_value">
</select>
</div>
<div ng-switch-when="p">
<p style="width: {{ question.size }};" data-isnull="{{question.isnull}}" name="{{question.dbcolumn}}" id="{{question.dbcolumn}}"><b>{{question.default_value}}</b></p>
</div>
<div ng-switch-default>
<!-- default action -->
</div>
</div>
</td>
<td>
<div ng-if="question.unity_variable == true">
<select>
<option ng-repeat="unit in question.unity">{{unit.value}}</option>
</select>
</div>
<div ng-if="!question.unity_variable">
{{question.unity}}
</div>
</td>
</tr>
</table>
我看过使用 AngularJS,如何将 <select> 元素绑定到通过服务更新的属性
在我的浏览器中,会显示标签,但不会显示选择中的选项。
在左侧,方法:
<select style="width: {{ question.size }};" data-isnull="{{question.isnull}}" name="{{question.dbcolumn}}" id="{{question.dbcolumn}}" ng-model="question" ng-options="choice.value for choice in question.default_value">
</select>
右边,方法:
<select style="width: {{ question.size }};" data-isnull="{{question.isnull}}" name="{{question.dbcolumn}}" id="{{question.dbcolumn}}">
<option ng-repeat="choice in question.default_value" value="{{choice.value}}">{{choice.name}}</option>
</select>
你能帮我找出我的错误吗?谢谢