我尝试在Angular应用程序中使用ui select,而不是select。我的问题是ui select不可见。
这是带选择的工作代码:
<select class = "form-control"
ng-model = "vm.user">
<option ng:repeat = "u in vm.users"
value = "{{u.id}}">
{{u.login}}
</option>
</select>
不使用ui选择的代码
<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