Where to include jQuery in Ionic index.html

14,397

Solution 1

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.

Solution 2

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.

Share:
14,397
Sam
Author by

Sam

Coder by day, Coder by night.

Updated on June 04, 2022

Comments

  • Sam
    Sam almost 2 years

    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.