[英]Where to include jQuery in Ionic index.html
I have a strange problem here. 我这里有一个奇怪的问题。
I am working on a Ionic (AngularJS) project and using jQuery in one of my controllers, so need to add the reference to it in index.html 我正在研究Ionic(AngularJS)项目,并在其中一个控制器中使用jQuery,因此需要在index.html中添加对其的引用
If I add reference like this - 如果我添加这样的参考-
<!-- jQuery js -->
<script type="text/javascript" src="lib/jquery/jquery-2.1.3.min.js"></script>
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
then, I get below error from one of the views - 然后,我从其中一种观点得到了错误-
Error: [$compile:ctreq] Controller 'ionTabs', required by directive 'ionTabNav', can't be found!
But, If I add reference like this - 但是,如果我添加这样的引用-
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- jQuery js -->
<script type="text/javascript" src="lib/jquery/jquery-2.1.3.min.js"></script>
then, I get below error from another one of the controllers, which was the reason I included jQuery in the first place - 然后,我从另一个控制器收到错误消息,这就是我首先包含jQuery的原因-
Error: [jqLite:nosel] Looking up elements via selectors is not supported by jqLite!
Not sure how to resolve this? 不确定如何解决此问题? I need to get both functionalities working. 我需要使两个功能同时工作。
Thanks in advance. 提前致谢。
Looks like this is a conflict between ionic and certain versions of jQuery . 看起来这是ionic和某些版本的jQuery之间的冲突。 https://github.com/driftyco/ionic/issues/1976 - switching the version of jQuery you are using should resolve. https://github.com/driftyco/ionic/issues/1976-可以解决切换使用的jQuery版本的问题。
I have a feeling that the problem here is not with a conflict between ionic (per se) and jQuery, but an issue with Angular and jQuery. 我感觉这里的问题不是与ionic(本身)和jQuery之间的冲突,而是与Angular和jQuery有关的问题。
Angular comes with a jQlite version of jQuery and that's probably what is conflicting. Angular带有jQuery的jQlite版本,这可能是矛盾的。 You might get some more information from this post on the Ionic Forum . 您可能会在Ionic论坛上从此帖子中获得更多信息。
Sorry I can't be more helpful, I'm only just starting out on my ionic adventures myself. 抱歉,我不能提供更多帮助,我只是开始自己的离子冒险。
You need to use jQuery Lite. 您需要使用jQuery Lite。 Read more at https://docs.angularjs.org/api/ng/function/angular.element 在https://docs.angularjs.org/api/ng/function/angular.element上阅读更多内容
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.