【发布时间】:2013-06-20 17:27:55
【问题描述】:
使用 ng-repeat 我在编辑表单中显示一些收音机:
<label style="float: left;margin-right: 3px;" data-ng-repeat="gender in genders" data-ng-hide="$first">
<input type="radio" name="gender" value="{{gender.Id}}" data-ng-model="customerFormData.customer.Gender.Id" />{{gender.Description}}
</label>
如您所见,我应用了“点练习”。编辑表单是我的详细信息表单上的弹出窗口。在我的详细表格中,我有这个:
<tr>
<td>Gender:</td>
<td>{{ customer.Gender.Description }} </td>
</tr>
我在编辑表单中的所有绑定都正常工作,但我无法让性别绑定正常工作。我认为这与使用 ng-repeat 进行范围继承有关。
我也尝试过使用$parent,但结果还是一样:
<label style="float: left;margin-right: 3px;" data-ng-repeat="gender in genders" data-ng-hide="$first">
<input type="radio" name="gender" value="{{gender.Id}}" data-ng-model="$parent.customerFormData.customer.Gender.Id" />{{gender.Description}}
</label>
设置初始值有效。当设置为女性时,选择女性无线电,当设置为男性时,选择男性无线电。
A second problem is (and I think it has to do with the binding), is that when Male is selected, I have to click twice on female to get female selected.
编辑:我创建了一个Fiddle 来说明我的问题。
【问题讨论】:
-
你能准备一份代码吗?
-
@callmekatootie 我添加了一个小提琴。查看我更新的帖子
标签: angularjs angularjs-scope angular-ui angularjs-ng-repeat