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 ])}
Adding jQuery to AngularYou need to create an Angular application using ng new command and then you need to 'cd' into that folder to install jQuery via NPM in the development environment.
Selectors and events are usually solved by libraries like React and Angular, so you don't need jQuery to help with browser compability and API differences.
Most likely you need to download and include the TypeScript declaration file for jQuery— jquery. d. ts —in your project. Then the compiler will resolve the definitions for jquery automatically.
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';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With