Skip to content Skip to sidebar Skip to footer

Import Jquery In Angular4

in order to import jquery in an angualr4 project i do the following: npm install --save jquery npm install --save-dev @types/jquery in the app.component.ts import $ from 'jquery';

Solution 1:

Try this

import * as $ from 'jquery/dist/jquery.min.js';

Solution 2:

Install jquery package using npm following is the code to install jquery

npm install jquery --save

Add types

npm install --save-dev@types/jquery

Add scripts to angular-cli.json

"apps":[{"scripts":["../node_modules/jquery/dist/jquery.min.js",// check your ref path it might be different.],}]

In component, you need to add

declarevarjquery:any;

Post a Comment for "Import Jquery In Angular4"