UI-Select reset-search-input does not work

2019-07-03 07:12发布

Please see my code below, when a choice is select from an input by typing something in i.e "Fr" and all the countries starting with France would appear, however after the input is selected the input field does not get cleared

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

2条回答
孤傲高冷的网名
2楼-- · 2019-07-03 07:47

The issue is still occurring in version 0.11.2.

As Dayan suggested in the comments, resetting the search in the on-select event solves it:

<ui-select multiple ng-model="numbers" on-select="numberSelected($select)">
...
</ui-select>

Then in your controller/directive:

scope.numberSelected = function ($select) {
    // clear search text
    $select.search = '';
};
查看更多
【Aperson】
3楼-- · 2019-07-03 07:50

You can set it at the global level using the uiSelectConfig constant like:

app.config(function(uiSelectConfig) {
  uiSelectConfig.resetSearchInput = true;
});

It worked for me.

查看更多
登录 后发表回答