【问题标题】:very strange issue with ng-selected and jqueryng-selected 和 jquery 的非常奇怪的问题
【发布时间】: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 中创建演示

标签: jquery angularjs


【解决方案1】:

Angular 附带了一个 jqLit​​e 版本,所以实际上你不需要加载外部 jQuery,除非你将 angular 添加到已经构建的解决方案中。

【讨论】:

    猜你喜欢
    • 2021-08-26
    • 1970-01-01
    • 1970-01-01
    • 2013-02-07
    • 1970-01-01
    • 2015-09-06
    • 2012-06-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多