问题
Please look at the following plunkr, when the data is loaded via $http I assign it to the model but the select doesn't update to the new value. But when changing the select the model updates correctly.
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:
In your plunkr your ng-options is this (not what you have above):
ng-options="ptypes.Description for ptypes in proptypes track by ptypes.ID"
If you change it to this:
ng-options="ptypes.ID as ptypes.Description for ptypes in proptypes"
It works. No need for the track by.
Updated plnkr: https://plnkr.co/edit/sy25TGPt87C2Nj2Qmzbn?p=preview
来源:https://stackoverflow.com/questions/36718995/angular-select-not-updating-after-model-updates