Import popular javascript library into Angular 2 project - Tuong-Nguyen/Angular-D3-Cometd GitHub Wiki
- Install JQuery:
npm install --save jquery
- Import to our file:
import * as $ from 'jquery'
- Import library in
index.html
:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
- Declare $ variable at top of any file where we want to use it:
declare let $: any
Same as JQuery
Note that when using a library through CDN, we can not test our code because of Reference error