Reputation: 583
I am working on to use the ng2-datetime. Installed through npm, but when I build the solution, I am getting an error that cannot find name 'jQuery'.
I have added the jQuery through npm and also tried to include the jquery library, but the issue still persists. Can anyone tell what else to include? I'm using angular 2.2 with typescript and my IDE is VS2015
app.module.ts
just added the import statement
import { NKDatetimeModule } from 'ng2-datetime/ng2-datetime';
and under imports
@NgModule({
imports:[NKDatetimeModule ])}
Upvotes: 24
Views: 43763
Reputation: 1
For me this method worked:
npm install jquery --save
npm install @types/jquery --save-dev
Adding jquery in angular.cli.json/angular.json, also check the path of jquery.min.js :
“scripts”: [ “../node_modules/jquery/dist/jquery.min.js”, “../node_modules/bootstrap/dist/js/bootstrap.js”]
Ensure bootstrap dependency is after jquery, if you are using bootstrap.
Upvotes: 0
Reputation: 3127
after installing jQuery
npm install jquery --save
and the jQuery TypeScript autocomplete
npm install @types/jquery --save-dev
now you have to add this reference "../node_modules/jquery/dist/jquery.min.js" to the Angular-cli.json file at the root of your angular Cli folder inside the Scripts: [] property. after that, jQuery will be available for you as a global variable, Great!
Upvotes: 10
Reputation: 4093
3 Steps:
Install jQuery. (skip if already installed)
npm install jquery --save
Install types for jQuery.
npm install @types/jquery --save
Import jQuery in app.module.ts.
import * as $ from 'jquery';
Upvotes: 94
Reputation: 8258
Its because your typings for jquery is not found, Use the following Command
typings install dt~jquery --save --global
If you want to save as a dependency remove "--global" flag
Upvotes: 2