Casper Deseyne
Casper Deseyne

Reputation: 331

How to force angular to use jqlite or manually reference the jquery object

I'm stuck with an incompatible version of jQuery in my Angular app, I can't upgrade jQuery but can load the latest jQuery version side by side using the noConflict method but I cant seem to find a way to force Angular.js to use the newer jQuery version. Is there such a method available?

Flow:

<head>
    <script src="jQuery 1.3.2">
    <script src="old jquery code">
</head>

<body>
    …

    <script src="jQuery 1.10.2"/>
        <script>
            var newjquery = jQuery.noConflict();
        </script>

        <script src="angular.js"/>

        <script>
            // angular code
        </script>
</body>

Upvotes: 6

Views: 2163

Answers (2)

TheBelgarion
TheBelgarion

Reputation: 330

you can use the new directive ng-jq with angular 1.4.x to set the Version of switch to jQLite (angular internal jQuery)

Upvotes: 6

fusio
fusio

Reputation: 3675

From the docs:

Does Angular use the jQuery library?

Yes, Angular can use jQuery if it's present in your app when the application is being bootstrapped. If jQuery is not present in your script path, Angular falls back to its own implementation of the subset of jQuery that we call jQLite.

Try to change the position in which you import the scripts:

  • new jquery
  • angular
  • older jquery

I am not sure it would work, but from my understanding Angular should use the already present jQuery.

Upvotes: 7

Related Questions