I want to use Jquery in my Angular2 application. I did the following:
- I installed using npm - package.json- "devDependencies": { "@types/jquery":"2.0.42" }
- I created a - jQuery.service.tsfile and declared an- OpaqueTokento expose this library- import { OpaqueToken } from '@angular/core' export let JQ_TOKEN = new OpaqueToken('jQuery');
- I imported and declared the - jQuerytoken in- app.module.ts- import {JQ_TOKEN} from './common/jQueryService' declare let jQuery : Object;
Now I am trying to access the $ of jQuery in my component.ts file
import {JQ_TOKEN} from './jQueryService'
export class simpleModal {
  @ViewChild('sessionModal') contentEl : ElementRef;
  constructor(private elRef : ElementRef, @Inject(JQ_TOKEN) private $ : any){}
  closeModal() {
    this.$(this.contentEl.nativeElement).modal('hide');
  }
}
And I get the following error:
Error: No provider for Token jQuery!
Can someone please guide me on why this error appears?
 
     
    