【发布时间】:2013-12-08 18:43:18
【问题描述】:
我使用 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, "" );
}
【问题讨论】:
-
你需要 jQuery 做什么? Angular 应该具备你需要的所有功能。
-
在开发过程中使用未缩小的开发版本,错误输出更详细。请在复制问题的 plunker 中创建演示