Ionic 2 RC1 doesn't import JQuery anymore (solution for Beta is not working)

Hi everybody,

I use:

Ionic Framework Version: 2.0.0-rc.1
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
OS: Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS
Node Version: v4.2.6

I need to reuse some JQuery stuff in my project.

I followed instructions jquery-in-ionic-2-and-typescript, but import * as $ from 'jquery' code is not working anymore. @leu2tm says about a similar problem jquery-is-not-defined-ionic-2-rc0.

Then i applied @scottlott solution to add jQuery js file manually… I reached to a point but still getting errors. Like @cyberabis said, I find the JS reference in src/index.html is getting wiped when built to www/index.html

I can’t import jQuery and even if I change index.html in www folder manually.

When i use:

import * as $ from ‘jquery’;

I get this error:

bundle failed: Cannot call a namespace (‘$’)

I tried “jQuery” and “JQuery” as well. Also I tried to change jquery.d.ts file, from:

declare module “jquery” {
export = $;
}

to:

declare module “jquery” {
export = jQuery;
}

Thus, my selectors are not working… Is there any instruction from zero to add jQuery to a Ionic 2 RC1 project with a simple example?

1 Like

I couldn’t resolve it, but it seems theres some kind of documentation about [third-party-libs] (http://ionicframework.com/docs/v2/resources/third-party-libs/).

Did you also add the typings file?

Sincerely,
leu2tm

I’ve added typings as well, but i gave up trying :frowning: