Install jQuery in Angular 8 Project
2 min readMay 28, 2020
- Create a new Angular 8 Project
- Use the following commands to install jQuery
npm install jquery --savenpm install @types/jquery --save
- Navigate to the root folder to edit the angular.json file
- Add the path to the jQuery min js file in the scripts field which would now be located in the node_modules folder
- Navigate to the root folder to edit the tsconfig.app.json file
- Add “jquery” to the types field
- Go to the app.component.ts file
- Add the following statement at the top
declare var $: any;
- Go to the desired component in which you would like to add jQuery to and add the following import statement at the top of the name_of_component.component.ts file.
import * as $ from "jquery";
- Try it out!
Here the ‘alertName’ function was created to grab the name and alert it.