2016-03-21 4 views
0

ここに私のコードです。角度のあるUI選択を使用しました。それは素晴らしい仕事です。しかし今、ドロップダウンが1回だけ選択されるように要件が変更されました。制限属性を使用しましたが、機能しません。単一選択によるユーザ選択(制限属性が機能していません)

<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

他の方法にはあり選択を1つに制限しますか? – tv3free

答えて

0

制限は0.13バージョン以降に導入されました。私が選択したオプションの値をクリアするために0.12

0

次のコードを使用を使用していた

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(); 
} 
関連する問題