我在项目中使用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>


但这是行不通的。如何在ng-options中使用ui-select

谢谢!!

最佳答案

请使用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

关于javascript - Angular 用户界面选择不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32432264/

10-17 03:02