SELECT2下拉列表选择的值不会获得更新后的模型更新 [英] select2 dropdown selected value doesn't get updated with the updated model

查看:637
本文介绍了SELECT2下拉列表选择的值不会获得更新后的模型更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的是最新的SELECT2 API(select2-3.4.5)和我的HTML代码中选择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);

我所有的文本字段被装入更新的数据,当我打印输出{{为MyModel}},我可以看到更新后的模型。
我进行保存并在$范围更新调用。$与更新DOM元素的意向申请。

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.

更新后,当我展开下拉(选择2),我可以看到选择选项里面选择了正确更新值。

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>

但选择2容器里面有

but select2-container which has

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

这是与选择2还是我失去了什么问题?

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

推荐答案

实际的问题是,选择2最新版本不具有角1.2兼容100%。请参阅以下链接。

The actual issue was that select 2 latest version was not 100% compatible with angular 1.2. See the following link.

https://github.com/angular-ui/ui-select2/问题/ 110

角UI选择2队自从更新了code,以解决这个问题。非常感谢他们。现在这个问题解决了。

angular UI select 2 team has since updated the code to fix this issue. Many thanks to them. now this issue is resolved.

这篇关于SELECT2下拉列表选择的值不会获得更新后的模型更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆