如何从 ngOptions 转换为 angular-ui-select?

How do I convert from ngOptions to angular-ui-select?

我正在尝试使用 angular-ui-select 指令为我的 select 添加可搜索性。当我使用 angular-ui-select 时,模型值变成整个时区,而不仅仅是 id。

代码如下:

<!-- select with ngOptions doing what I want -->
<select data-ng-model="clock.time_zone_id" data-ng-options="timeZone.id as timeZone.name for timeZone in timeZones"></select>

<!-- my best try with angular-ui-select -->
<ui-select data-ng-model="clock.time_zone_id" theme="selectize">
  <ui-select-match>{{$select.selected.name}}</ui-select-match>
  <ui-select-choices repeat="timeZone in timeZones | filter: $select.search">
    <span ng-bind-html="timeZone.name | highlight: $select.search"></span>
  </ui-select-choices>
</ui-select>

我错过了什么?如果有任何帮助,我将不胜感激!

这应该有效:

<ui-select data-ng-model="clock.time_zone_id" theme="selectize">
  <ui-select-match>{{$select.selected.name}}</ui-select-match>
  <ui-select-choices repeat="timeZone.id as timeZone in timeZones | filter: $select.search">
    <span ng-bind-html="timeZone.name | highlight: $select.search"></span>
  </ui-select-choices>
</ui-select>