2

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

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.

0

3 Answers 3

3

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

Sign up to request clarification or add additional context in comments.

2 Comments

Oh man! I hope this gets resolved soon. I switched to jQuery 1.11.2 and included it before ionic.bundle.js statement.
i had the same issue, adding jquery before ionic.bundle.js fixed it thanks!
1

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 comes 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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.