Dropdown already selected

0

I made a dropdown with AngularJs as follows

<ui-select ng-model="SelectedItem.LegalEntity" 
            theme="bootstrap"
            reset-search-input="false"
            style="width: 100%"
            id="legalEntityId"
            ng-disabled="disabled">
           <ui-select-match placeholder="">{{$select.selected.Name}}</ui-select-match>
               <ui-select-choices repeat="entity in legalEntities">
                <div ng-bind-html="entity.Name | highlight: $select.search"></div>
               </ui-select-choices>
           </ui-select>

When the dropdown has only 1 item in the list, I want to block the dropdown and leave the first item already selected.

I can already block using ng-disable, but I could not load the page with the first dropdown item selected.

    
asked by anonymous 09.03.2016 / 15:51

1 answer

1

To pre-load ui-select with some value just assign the list to the ng-model variable in the controller:

var legalEntities = [{Name: 'nameDaEntity'}];

$scope.SelectedItem.LegalEntity = legalEntities;
    
11.03.2016 / 05:52