eugenekgn
eugenekgn

Reputation: 1722

UI-Select reset-search-input does not work

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>

Upvotes: 3

Views: 6937

Answers (2)

Rhumborl
Rhumborl

Reputation: 16609

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

Upvotes: 4

Nathan Kummel
Nathan Kummel

Reputation: 98

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

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

It worked for me.

Upvotes: 3

Related Questions