Kalhan.Toress
Kalhan.Toress

Reputation: 21901

How to clear selected value in angular-ui select2

Im using angular-ui select2 plugin I cant find any solution for clear the selected input. how to clear the selected input ? thanks.

<http://plnkr.co/edit/a3KlK8dKH3wwiiksDSn2?p=preview>

I want somethig like this.

enter image description here

Upvotes: 2

Views: 3356

Answers (1)

Yuriy A.
Yuriy A.

Reputation: 752

Here are two options:

1 - You could use standart attribute allow-clear="true"

  <ui-select ...>
    <ui-select-match allow-clear="true" ...>{{$select.selected.name}}</ui-select-match>
    ...
  </ui-select>

OR

2 - You could add a button

<ui-select-match placeholder="Select or search a country in the list...">
  <span>...</span>
  <button class="clear" ng-click="clear($event)">X</button>
</ui-select-match>

$scope.clear = function($event) {
   $event.stopPropagation(); 
   $scope.country.selected = undefined;
};

Upvotes: 1

Related Questions