ng-selected和jquery非常奇怪的问题

时间:2013-12-08 18:43:19

标签: jquery angularjs

我使用AngularJS v1.2.3和jQuery 1.7.1,这些库包含在以下排序顺序中:

<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="angular.min.js"></script>

以下脚本以奇怪的方式工作,Firebug显示项目#2具有“已选择”属性,但我看到#1已选中!

<select ng-app>
        <option value="1" ng-selected="3==1">#1</option>
        <option value="2" ng-selected="2==2">#2</option>
        <option value="3" ng-selected="1==3">#3</option>
</select> 

当我更改脚本的排序顺序(jquery之前的angularjs)时,代码按预期工作。

我该怎么做才能防止这个问题?我无法更改脚本的排序顺序

更新: 这是jQuery 1.7.1的错误:

// See #9699 for explanation of this approach (setting first, then removal)
jQuery.attr( elem, name, "" );

后来修好了:

// Do not do this for boolean attributes (see #10870)
if ( !isBool ) {
  jQuery.attr( elem, name, "" );
}

1 个答案:

答案 0 :(得分:0)

无论如何,Angular都有一个版本的jqLit​​e,所以你不需要加载外部jQuery,除非你为已经构建的解决方案添加了角度。