【问题标题】:angular ui select is not working角度 ui 选择不起作用
【发布时间】:2015-09-07 06:21:57
【问题描述】:

我在我的项目中使用 angular ui select https://github.com/angular-ui/ui-select。我正在使用ui-select 指令

我的代码:

<select class="input-small" ng-model="dashboard.style" ng-options="f for f in ['light','hpexp']" ng-change="styleUpdated()"></select>

我想用 ui-select 所以我做了,

<ui-select id="viewSelector"
    class="viewSelector input-small"
    ng-model="dashboard.style"
    ng-options="f for f in ['light','hpexp']" 
    ng-change="styleUpdated()"
    theme="selectize"> 
<ui-select-match placeholder="-- Select --">
   {{$select.style}}</ui-select-match>
</ui-select>

但它不起作用。如何在ui-select中使用ng-options

谢谢!!

【问题讨论】:

  • 你能在 fiddler 中添加这段代码吗?
  • 当然……让我试试……

标签: javascript jquery angularjs angular-ui-select


【解决方案1】:

请使用ui-select-choices 而不是ng-options。让我们试试下面的代码,而不是你的代码

<ui-select id="viewSelector"
        class="viewSelector input-small"
        ng-model="dashboard.style"  
        ng-change="styleUpdated()"
        theme="selectize"> 
    <ui-select-match placeholder="-- Select --">
       {{$select.style}}</ui-select-match>
    <ui-select-choices repeat="f for f in ['light','hpexp']">
          <div ng-bind-html="f"></div>
        </ui-select-choices>
    </ui-select>

更多细节,请阅读此讨论

Angularjs and UI-Select: how to select an option from code

【讨论】:

  • collection_[track by _id]' 中的预期表达式为 'item,但得到了 'f for f in ['light',' hpexp']'。收到此错误
  • 谢谢,试试这个repeat="f in ['light','hpexp']"
  • 但在选择任何选项时.. {{$select.style}} 它没有显示任何东西..如果你能帮助它会很棒
猜你喜欢
  • 1970-01-01
  • 2017-03-10
  • 1970-01-01
  • 2013-12-08
  • 2020-05-26
  • 1970-01-01
  • 1970-01-01
  • 2016-10-17
  • 2019-09-23
相关资源
最近更新 更多