Angular选择模型更新后不更新

时间:2016-04-19 12:52:10

标签: angularjs html-select

请查看以下plunkr,当通过$ http加载数据时,我将其分配给模型,但select不会更新为新值。但是在更改选择时,模型会正确更新。

https://plnkr.co/edit/UJMeR0gregFaavhT5wxs?p=preview

<select id="proptype_id" class="form-control"
    ng-model="proptype_id"
    ng-options="ptypes.id as ptypes.Description for ptypes in proptypes track by ptypes.id"
    >

1 个答案:

答案 0 :(得分:0)

在你的插件中你的ng-options就是这个(不是你上面的那个):

ng-options="ptypes.Description for ptypes in proptypes track by ptypes.ID"

如果您将其更改为:

ng-options="ptypes.ID as ptypes.Description for ptypes in proptypes"

有效。不需要赛道。

更新了plnkr:https://plnkr.co/edit/sy25TGPt87C2Nj2Qmzbn?p=preview