最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Where to include jQuery in Ionic index.html - Stack Overflow

programmeradmin1浏览0评论

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

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: [$pile: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 -

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.

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

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: [$pile: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 -

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.

Share Improve this question asked Mar 8, 2015 at 21:26 SamSam 4,48412 gold badges43 silver badges75 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 3

Looks like this is a conflict between ionic and certain versions of jQuery . https://github./driftyco/ionic/issues/1976 - switching the version of jQuery you are using should resolve.

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.

Angular es with a jQlite version of jQuery and that's probably what is conflicting. You might get some more information from this post on the Ionic Forum.

Sorry I can't be more helpful, I'm only just starting out on my ionic adventures myself.

You need to use jQuery Lite. Read more at https://docs.angularjs/api/ng/function/angular.element

发布评论

评论列表(0)

  1. 暂无评论