In ui-select
, when I select an option, the on-select
callback does fire, but the option does not clear every second time.
The ui-select has 2 states:
- Button - when I do not actually click it
- Input - when I click in it and it lets me search
When it starts, the button has my placeholder text "Search...". I click it, start to search, it brings up a list, I select one option, on-select
fires, in which I clear the ng-model
.
Yet, every second select I do, it ignores the ng-model
clear in my callback.
<ui-select ng-model="result.selected" theme="bootstrap" class="search" on-select="searchselect($item)" reset-search-input="true" on-select="selected($item)">
<ui-select-match placeholder="Search...">{{$select.selected.name}}</ui-select-match>
<ui-select-choices refresh="search({val:$select.search})" refresh-delay="300" repeat="item in results">
<div ng-bind="item.name"></div>
</ui-select-choices>
</ui-select>
Here is my on-select
code:
$scope.selected = function(item) {
$scope.picked = item;
$scope.result.selected = "";
};
I modified the basic ui-select
example plunkr to replicate it: http://plnkr.co/edit/16DRYH8MbPJOy0GpogZz?p=preview
- Click on the select
- Search for text, I find "123" to be easiest
- Select an option
- See that the
ng-model
is cleared - Search again
- Select another option, or the same one
- See that the
ng-model
is not cleared
Here are images.
Initial:
During search:
After select (every 2nd one) - this is my problem
Why is it not cleared in the button last image after every 2nd select?