2014-10-07 47 views

回答

1

這裏有兩種選擇:

1 - 你可以使用非標準的屬性allow-clear="true"

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

OR

2 - 你可以添加一個按鈕

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