I have tried number of methods posted on StackOverflow to use jquery-ui in angular 6 component but none of them worked. For example,
<Please update your scripts part in angular.json file
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/jquery-ui-dist/jquery-ui.js"
]
If you write
import * as $ from 'jquery';
then only the code for jquery
(and not extra plugins, like jquery-ui
) will be imported by typescript compiler into the $
variable.
If you use
declare let $: any;
Then you are just notifying typescript that this variable exist. In that case, $
will contain whatever what assigned to it in the scripts you imported in angular.json
, which is jquery
AND jquery-ui
plugins