簡體   English   中英

ui-select不可見

[英]ui-select is not visible

我嘗試使用ui-select代替在Angular應用中選擇。 我的問題是ui-select不可見。

這是帶有select的工作代碼:

    <select class = "form-control"
            ng-model = "vm.user">
        <option ng:repeat = "u in vm.users"
                value = "{{u.id}}">
            {{u.login}}
        </option>
    </select>

ui-select無法正常工作

   <ui-select  ng-model = "vm.user"
               style = "width: 300px; height: 50px">
        <ui-select-choices repeat = "u in vm.users">
            <div ng-bind-html = "u.login"></div>
        </ui-select-choices>
    </ui-select>

index.html

    <!-- UI-Select -->
    <link href = "content/select.min.css"
          rel = "stylesheet" />
    <!-- Angular -->
    <script src = "scripts/angular.min.js"></script>
    <!-- UI-Select -->
    <script src="scripts/select.min.js"></script>

知道有什么問題嗎?

您還必須使用ui-select-match指令。 否則將不會顯示。

<ui-select-match placeholder="do select..">
  {{$select.selected.login}}
</ui-select-match>

您可以執行以下操作:

  • 添加依賴項:
angular.module('something', ['ui.select'])
  • 使用如下代碼:
<ui-select ng-model="vm.user" style="width: 300px; height: 50px;">
    <ui-select-match placeholder="Select user...">
        {{$select.selected.name}}
    </ui-select-match>
    <ui-select-choices repeat="user in vm.users | filter: $select.search">
        <div ng-bind-html="user.name | highlight: $select.search"></div>
    </ui-select-choices>
</ui-select>
  • 我認為ui-select對您不可見。 如果沒有看到下拉菜單,則可能是由以下問題之一引起的:

https://github.com/angular-ui/ui-select/issues/1731

https://github.com/angular-ui/ui-select/issues/1652

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM