zubair1024
10/23/2017 - 5:31 PM

installing jquery to ionic

installing jquery to ionic

First of all, install JQuery in your ionic2 project:

$ npm install jquery --save
After that, install JQuery global derectory to typings (so you can import it):

$ typings install dt~jquery --global --save
Then, you can import JQuery ib your "home.ts":

import * as $ from 'jquery'
That worked for me without problems.

Checking:

For checking if it is working, you can simply try the following:

In your: "home.html":
<button id="x" (click)="changeColor()">Click Me!</button>

In your: "home.ts":
changeColor(){
  $('#xn').text('white');
}

I hope it works for you!