how to use jquery-ui in angular 6

后端 未结 2 692
孤城傲影
孤城傲影 2020-12-11 04:56

I have tried number of methods posted on StackOverflow to use jquery-ui in angular 6 component but none of them worked. For example,

<
2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-11 05:37

    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

提交回复
热议问题