npm install jquery --save
npm install @types/jquery --save-dev
// .angular.cli.json
...
"scripts": [
"..node_modules/jquery/dist/jquery.min.js"
]
...
// src/tsconfig.app.json
...
"types": ["jquery"]
...
import {Component, ElementRef, OnInit} from '@angular/core';
@Component({
selector: 'simple-component',
templateUrl: './simple.component.html',
styleUrls: ['./simple.component.scss']
})
export class SimpleComponent implements OnInit {
constructor(private elementRef: ElementRef) {}
ngOnInit() {
jQuery(this.elementRef.nativeElement).html('jquery')
}
}