我有一个这样的选择框:
<select class="form-control"
ng-model="contactName"
ng-change="testFun(contactName)"
ng-options="contact.Id as contact.Name + ' ' + contact.Surname for contact in company.items.contacts"
ng-selected="$scope.contactId === contact.Id">
</select>
其中 $scope.contactId = 14151 和 contact.Id = 14151
但是选择框仍然没有选择正确的人 en 仍然显示为空白。
我无法弄清楚我在这里做错了什么。
编辑
<select class="form-control"
ng-model="contactName"
ng-change="testFun(contactName)"
ng-options="contact.Id as contact.Name + ' ' + contact.Surname + ' id:' + contact.Id for contact in company.items.contacts"
ng-selected="contactId == contact.Id">
</select>
<pre>
contactId: {{contactId}}
</pre>
这会导致以下结果,这也证实了 ID 是相同的: ContactId Option with the same ID
盒子仍然是空白的