私は最新の select2 API (select2-3.4.5) を使用しており、select 2 の html は次のようになっています。
<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>
モデルを保存し、保存したモデルをリロードするコントローラーで保存呼び出しを実行しています。これは、次のブロック内で行われます。
$timeout(function(){
//if(!$scope.$$phase){
$scope.$apply(function(){
//update the model
//update code
})
//};
}, 50);
すべてのテキスト フィールドに更新されたデータが読み込まれ、{{mymodel}} を印刷すると、更新されたモデルが表示されます。dom 要素を更新する目的で、 $scope.$apply 内で保存と更新の呼び出しを実行しました。
更新後、ドロップダウン (select2) を展開すると、選択オプション内で正しく更新された値が選択されていることがわかります。
<option XXXX selected="selected">MYSELECTED</option>
しかし、持っているselect2-container
<span class="select2-chosen">OLD</span> has the old value hence it is shown as the selected value.
これはselect 2の問題ですか、それとも何か不足していますか?