【问题标题】:ui-select is not visibleui-select 不可见
【发布时间】:2016-10-27 17:28:23
【问题描述】:

我尝试使用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 模块添加为您的应用程序的依赖项?我猜不会。
  • @Pierre Gayvallet:不,我忘记了,请发表答案我会接受...谢谢

标签: angularjs ui-select


【解决方案1】:

您还必须使用 ui-select-match 指令。否则不会显示。

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

【讨论】:

    【解决方案2】:

    你可以这样做:

    • 添加依赖:
    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-23
      • 2020-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多