【问题标题】:Angular UI Select2 in the Bootstrap Navigation BarBootstrap 导航栏中的 Angular UI Select2
【发布时间】:2012-11-24 13:42:20
【问题描述】:

Bootstrap 导航栏中 Angular-UI 的 Select2 报错

TypeError: Object [[object HTMLInputElement]] has no method 'is'

请参考http://plnkr.co/edit/yCG5M9

【问题讨论】:

  • 请详细解释您的答案。
  • @jm- 的答案是正确的。我在他的帖子中添加了解释。

标签: twitter-bootstrap angularjs jquery-select2 angular-ui


【解决方案1】:

你需要在AngularJS之前加载jQuery

只需将顺序更改为

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>

EDIT(blesh):这是因为如果 angular 在加载时看不到 JQuery,那么传递给 compile 函数的 tElm(角度元素)参数就是 jqLit​​e目的。如果 Angular 发现 JQuery 已被加载首先tElm 将是一个完整的 JQuery 对象,is() 将可用。

【讨论】:

  • 这是正确答案,我只是添加了为什么这是正确答案的解释。
  • 但是在更改脚本导入的顺序后,Bootstrap 导航折叠不起作用。响应式设计的折叠按钮不起作用。请查看更新后的链接plnkr.co/edit/yCG5M9
猜你喜欢
  • 2014-07-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-13
  • 2014-09-14
  • 2015-05-24
  • 2017-12-19
  • 2018-06-12
相关资源
最近更新 更多