UI-Select 重置搜索输入不起作用
UI-Select reset-search-input does not work
请看下面我的代码,当通过在 "Fr" 中键入内容从输入中选择 select 时,所有以法国开头的国家/地区都会出现,但是在输入 select输入字段没有被清除
<ui-select multiple
ng-model="quote.targetLanguage"
reset-search-input="true"
theme="bootstrap"
ng-disabled="disabled"
close-on-select="false"
style="width: 800px;">
<ui-select-match placeholder="Select person...">
{{$item.language}}
</ui-select-match>
<ui-select-choices repeat="lang in controllersData.languages | filter: $select.search">
<div ng-bind-html="lang.language | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
您可以使用 uiSelectConfig 常量在全局级别进行设置,例如:
app.config(function(uiSelectConfig) {
uiSelectConfig.resetSearchInput = true;
});
对我有用。
该问题在版本 0.11.2 中仍然存在。
正如 Dayan 在评论中建议的那样,在 on-select
事件中重置搜索可以解决问题:
<ui-select multiple ng-model="numbers" on-select="numberSelected($select)">
...
</ui-select>
然后在你的 controller/directive:
scope.numberSelected = function ($select) {
// clear search text
$select.search = '';
};
请看下面我的代码,当通过在 "Fr" 中键入内容从输入中选择 select 时,所有以法国开头的国家/地区都会出现,但是在输入 select输入字段没有被清除
<ui-select multiple
ng-model="quote.targetLanguage"
reset-search-input="true"
theme="bootstrap"
ng-disabled="disabled"
close-on-select="false"
style="width: 800px;">
<ui-select-match placeholder="Select person...">
{{$item.language}}
</ui-select-match>
<ui-select-choices repeat="lang in controllersData.languages | filter: $select.search">
<div ng-bind-html="lang.language | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
您可以使用 uiSelectConfig 常量在全局级别进行设置,例如:
app.config(function(uiSelectConfig) {
uiSelectConfig.resetSearchInput = true;
});
对我有用。
该问题在版本 0.11.2 中仍然存在。
正如 Dayan 在评论中建议的那样,在 on-select
事件中重置搜索可以解决问题:
<ui-select multiple ng-model="numbers" on-select="numberSelected($select)">
...
</ui-select>
然后在你的 controller/directive:
scope.numberSelected = function ($select) {
// clear search text
$select.search = '';
};