How to Include and Use jQuery in Angular CLI Project

Pubblicato il: 22 ottobre 2021
sul canale di: v11tv
264
1

Steps below:

First, install jQuery using npm as follows:
npm install jquery — save

Second, go to the ./angular.json file at the root of your Angular CLI project folder, and find the scripts: [] property, and include the path to jQuery as follows:
"scripts": [ "./node_modules/jquery/dist/jquery.min.js" ]

Note: If you want to use bootstrap in your application, or if you already have in your project, make sure to include jQuery before including the bootstrap JavaScript file

After including jQuery, stop running your Angular CLI application. Then, re-run it using
Ng serve --open

Now, to use jQuery, all you have to do is to import it in whatever component you want to use jQuery.
import * as $ from 'jquery';
or

Declare var $:any;

#channel11angular #angularjquery #angularincludejquery


In questa pagina del sito puoi guardare il video online How to Include and Use jQuery in Angular CLI Project della durata di ore minuti seconda in buona qualità , che l'utente ha caricato v11tv 22 ottobre 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 264 volte e gli è piaciuto 1 spettatori. Buona visione!