Reputation: 1444
I am trying to use bootstrap selectpicker in my angular2 application. I have loaded jquery and bootstrap-select scripts in angular-cli.json.
This is my app-component.ts
import $ from 'jquery';
ngOnInit() {
$('.selectpicker').selectpicker('refresh');
}
But, I am getting this error.
__WEBPACK_IMPORTED_MODULE_2_jquery___default(...)(...).selectpicker is not a function.
I am new to angular2. Please help!
Upvotes: 2
Views: 1881
Reputation: 466
Here is my Solution,
Open typings.d.ts file in angular-cli and add the following lines
interface JQuery {
addClass(className: string): JQuery;
attr(attributeName: string, value: string|number): JQuery;
}
interface JQuery {
selectpicker(options?: any, callback?: Function):any;
}
Don't import jquery instead:
declare var $:any;
Upvotes: 4