2

I use the latest select2 api (select2-3.4.5) and my html for select 2 looks like this.

     <select ui-select2 id="select2-test" ng-model="mymodel.myTitle">
        <option value="">Title</option>
        <option ng-repeat="title in nameList" value="{{title.key}}">{{title.name}}</option>
    </select>

I am performing a save call in my controller which saves the model and reloads the saved model back. This is done inside the following block.

     $timeout(function(){
        //if(!$scope.$$phase){
            $scope.$apply(function(){
                //update the model
                //update code
            })
        //};
    }, 50);

all my text fields gets loaded with the updated data and when I printout {{mymodel}}, I can see the updated model. I performed save and update call inside $scope.$apply with the intention of updating the dom elements.

after the update when I expand the dropdown (select2), I can see the correctly updated value selected inside the select options.

       <option XXXX selected="selected">MYSELECTED</option>

but select2-container which has

        <span class="select2-chosen">OLD</span> has the old value hence it is shown as the selected value.

Is this an issue with select 2 or am I missing anything?

Sanath
  • 4,774
  • 10
  • 51
  • 81

0 Answers0