Utiliser un plugin jquery
Bonjour, je souhaite utiliser un plugin jquery dans mon fchier ts.
J'ai importé la librairie et installer ce qu'il fallait dans le json:
Code:
1 2 3 4
| "scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/tablesorter/dist/js/jquery.tablesorter.min.js",
], |
Du coté composant :
Code:
1 2 3 4 5 6 7
| import * as $ from "jquery";
window['$'] = window['jQuery'] = $;
ngAfterViewInit()
{
$('TABLE').tablesorter({sortList: [[6, 0]],widthFixed: true});
} |
le $ semble bien reconnu. Pour pouvoir compiler j'ajoute une interface :
Code:
interface JQuery { tablesorter(options?: any): any;}
A ce stade le compilateur ne retourne plus d'erreur . Mais ma page elle si!! :
Citation:
ERROR TypeError: jquery__WEBPACK_IMPORTED_MODULE_2__(...).tablesorter is not a function
J'avoue que je sèche un peu la ^^
Si qq'un voit ou est le soucis je suis preneur.