Bootstrap 导航栏中的 Angular UI Select2 [英] Angular UI Select2 in the Bootstrap Navigation Bar

查看:24
本文介绍了Bootstrap 导航栏中的 Angular UI Select2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Bootstrap 导航栏中 Angular-UI 的 Select2 出现错误

Select2 of the Angular-UI in Bootstrap navigation bar is giving error

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

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

推荐答案

你需要在AngularJS之前加载jQuery

You need to load jQuery before AngularJS

只需将顺序更改为

<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,那么 tElm(angular 元素)参数将被传递到该 compile 函数是一个 jqLit​​e 对象.如果 Angular 看到 JQuery first 已经加载,tElm 将是一个完整的 JQuery 对象,并且 is() 将可用.

EDIT (blesh): This is because if angular doesn't see JQuery as it's loading, then the tElm (angular element) argument being passed into that compile function is a jqLite object. If Angular sees JQuery has been loaded first, the tElm will be a full JQuery object, and is() will be available.

这篇关于Bootstrap 导航栏中的 Angular UI Select2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆