UI-Select reset-search-input does not work

泄露秘密 提交于 2019-12-10 17:42:45

问题


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>

回答1:


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

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

It worked for me.




回答2:


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 = '';
};


来源:https://stackoverflow.com/questions/28573688/ui-select-reset-search-input-does-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!