【问题标题】:Angularjs with jquery.chosen - ngModel does not get updated带有 jquery.chosen 的 Angularjs - ngModel 没有得到更新
【发布时间】:2014-02-13 01:24:13
【问题描述】:

我正在使用https://github.com/localytics/angular-chosen 指令来创建简单的多选控件。

这应该很简单,但是 select 上的 ngModel 没有得到更新。

这里是角度控制器代码:

var app = angular.module('Simple', ['localytics.directives'])

.controller('SimpleCtrl', function ($scope, $http) {

    $scope.states = ['one', 'two', 'three', 'four']

    $scope.state = ['one'];

});

HTML:

<select multiple
     chosen
     ng-model="state"
     ng-options="s for s in states">
     <option value=""></option>
</select>

<p ng-repeat="s in state">{{s}}</p>

除了“状态”之外的所有东西都不会更新。我正在使用 angularjs 1.2.10。 我会很感激任何建议。谢谢。

这是提出相同问题的 jsfiddle http://jsfiddle.net/mousenine/MQzXq/12/

【问题讨论】:

    标签: javascript jquery angularjs jquery-chosen


    【解决方案1】:

    问题的根源是我在 jquery 之后包含了 angular.js。在 jsfiddle 中也是这样。

    一旦颠倒顺序(先是 jquery,然后是 angular),它就开始正常工作了。

    我在这里找到了 https://github.com/angular/angular.js/wiki/Understanding-Directives#wiki-element--angularelement--jquery-- 的捕获点

    【讨论】:

      猜你喜欢
      • 2023-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-08
      • 2017-04-19
      • 1970-01-01
      • 1970-01-01
      • 2013-06-04
      相关资源
      最近更新 更多