2016-03-21 14 views
0

Hier ist mein Code. Ich habe eckige UI-Auswahl verwendet. Es funktioniert großartig. Aber jetzt hat sich die Anforderung geändert, dass das Dropdown nur einmal ausgewählt wird. Ich habe Limit-Attribut verwendet, aber es funktioniert nicht.ui-Select mit einzelner Auswahl (Limit-Attribut funktioniert nicht)

<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

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

Controller-Aktion-Code löschen gibt es eine andere Art und Weise zu Beschränken Sie die Auswahl auf nur einen? – tv3free

Antwort

0

Grenzwert wurde nach Version 0.13 eingeführt. Ich war mit 0,12

0

Verwenden folgenden Code gewählte Option Wert

HTML-Code

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