【发布时间】:2015-02-07 13:41:54
【问题描述】:
我们一直在使用 ui-select (https://github.com/angular-ui/ui-select) 来设置 select2 等下拉菜单的主题。此功能在很大程度上与一个方面不同:默认占位符。
代码主要遵循 ui-select 演示(此页面上的第三个示例:http://plnkr.co/edit/a3KlK8dKH3wwiiksDSn2?p=preview)。
就我而言,默认文本应该是“占位符”属性的文本。相反,它显示为空白,直到您选择一个选项。我们一直在使用一种技巧,即在 Angular 控制器中设置 ui-select-match 的值来解决这个问题,但这远非完美,显然也不是应该如何使用它。
<ui-select data-ng-model="producttype.selected" theme="select2" name="product-type">
<ui-select-match placeholder="Select a product type">
{{$select.selected.title}}
</ui-select-match>
<ui-select-choices repeat="producttype in productTypeOptions | filter: $select.search">
<span ng-bind-html="producttype.title | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
以前有没有人遇到过这个问题,或者知道我们做错了什么?
【问题讨论】:
标签: javascript angularjs select angularjs-select2 ui-select