繁体   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