首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将ngOptions转换为角用户界面选择?

如何将ngOptions转换为角用户界面选择?
EN

Stack Overflow用户
提问于 2015-03-30 16:50:38
回答 1查看 2.2K关注 0票数 0

我试图添加搜索到我的选择与角-ui-选择指令。当我使用角-ui-选择时,模型值会变成整个时区,而不仅仅是id。

下面是代码:

代码语言:javascript
复制
<!-- 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>

我遗漏了什么?我很感谢你的帮助!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-30 19:04:20

这应该是可行的:

代码语言:javascript
复制
<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>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29351837

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档