Вот мой код. Я использовал угловой пользовательский интерфейс. Он отлично работает. Но теперь требование изменилось, чтобы выпадающий список был выбран только один раз. Я использовал атрибут limit, но не работал.
<span id="oCountriesSpan" ng-class="{'has-error': noCountriesSelected()}">
<ui-select multiple limit="1" ng-model="countryModel.selectedCountries" ng-disabled="isReadOnly" theme="bootstrap">
<ui-select-match placeholder="Select ..." allow-clear="true">{{$item.name}}
</ui-select-match>
<ui-select-choices repeat="country.id as country in countryCodes | filter:$select.search">
{{ country.name }}
</ui-select-choices>
</ui-select>
</span>
Лимит был введен после версии 0.13. Я использовал 0.12
Используйте следующий код, чтобы очистить выбранное значение параметра
Код HTML
<ui-select-match placeholder="Enter table…">
<span>{{$select.selected.description || $select.search}}</span>
<a class="btn btn-xs btn-link pull-right" ng-click="clear($event, $select)"><i class="glyphicon glyphicon-remove"></i></a>
</ui-select-match>
Код действия контроллера
function clear($event, $select){
//stops click event bubbling
$event.stopPropagation();
//to allow empty field, in order to force a selection remove the following line
$select.selected = undefined;
//reset search query
$select.search = undefined;
//focus and open dropdown
$select.activate();
}