I have tried running the following npm install but it doesnt fix anything. npm install jquery --save npm install @types/jquery --save-dev
I have added "scripts": ["../node_modules/jquery/dist/jquery.min.js"], in .angular-cli.json file.
app.component.ts
import { Component } from '@angular/core';
declare var $:any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'jQuery works!';
onToggle(){
$('.test').slideToggle();
}
}
Error: $ is not defined