Angular6Jquery

How to run jQuery in Angular 6?

Run jQuery in Angular 6 - The Rich Post

Angular 6 Material Datatables example with Php Mysql data
6.61KViews

Hello to all, welcome to therichpost.com. In this post, I will tell you, How to run jQuery in Angular 6?

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

Here are the following steps to run or include jQuery into your Angular 6 app:

1. First you need to run below command into your terminal:
  $ npm install jquery --save
2. Add below jquery file path into your angular.json file:
"scripts": ["node_modules/jquery/dist/jquery.js"]
3. Import jquery file into your app.module.ts file:
import * as $ from 'jquery';
4. Declare and finally add jquery code into your app.component.ts file:
declare var $: any;

export class AppComponent {

  ngOnInit() {

  $('body').addClass('df');

  }

}

And you are done.

jquery-angular6

If you have any query related to this post then you can ask question or comment below.

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. 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.

3 Comments

Leave a Reply

Positive SSL