Add and Run Jquery in Angular 7

Add and Run Jquery in Angular 7


Hello to all, welcome to In this post, I will tell you, Add and Run Jquery in Angular 7.

Angular is growing very fastly and popular as single page application. Today I am working with Angular 7 and wanted to run some jquery methods and I succeed and I am sharing that tricks what I did on my app.

I have written so many post related to jQuery because jQuery is my first love and today I also use jQuery in my many projects.

Here is the working image, I added dynamic class to body tag with jQuery:


Add and Run Jquery in Angular 7


Here is the working and tested code and you need to follow and into your Angular 7 application:


1. Very first, you need to run below command into your terminal :

$ npm install jquery --save


2. Now, you need to add below jquery file path into your Angular 7 application angular.json file:



"scripts": ["node_modules/jquery/dist/jquery.js"]


3.  Now you need to add below code into your app.component.ts file:

import * as $ from 'jquery';

export class AppComponent {

  ngOnInit() {




4. In this end run your Angular 7 application and you will see, new class will be added to body tag.

if you have any query related to this post, then please do comment below or ask question.

Thank you,





Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to Myself Ajay Malhotra and I am full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.


  • i did all steps what u said,
    but got errors when i aam column resizing using jquery .
    the error llike
    TypeError: jquery__WEBPACK_IMPORTED_MODULE_1__(…).css(…).prepend(…).resizable is not a function

    Uncaught ReferenceError: jQuery is not defined

    my code is
    import { Component, OnInit } from ‘@angular/core’;
    import * as $ from ‘jquery’;

    selector: ‘app-root’,
    templateUrl: ‘./app.component.html’,
    styleUrls: [‘./app.component.css’]
    export class AppComponent implements OnInit{
    title = ‘tables’;

    ngOnInit() {
    alert(“$ vesion is “+jQuery.fn.jquery)
    /* required to allow resizer embedding */
    position: “relative”
    /* check .resizer CSS */
    resizeHeight: false,

    // we use the column as handle and filter
    // by the contained .resizer element
    handleSelector: “”,
    onDragStart: function(e, $el, opt) {
    // only drag resizer
    if (!$(“resizer”))
    return false;
    return true;


    html code is

    Drag and Resize

    Table Head
    Table Head
    Table Head
    Table Head

    Table Data
    Table Data
    Table Data
    Table Data 12412412414124

    • HI Paparao, it seems like, you are jquery ui elements so you’re getting this error.
      Try to use :

      declare let $: any;
      instead of
      import * as $ from ‘jquery’;

      ———-or ————-

      1 : Import jquery-ui-dist
      npm install jquery jquery-ui-dist

      2: Add scripts in angular-cli.json
      “scripts”: [

      Thank you

  • That’s nice , great idea I will try to use it because you know not all UI plugins have angular7 implementation yet . So you are my hero 👍

Leave a Reply

Positive SSL