how to use jquery-ui in angular 6

后端 未结 2 681
孤城傲影
孤城傲影 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:31

    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"
            ]
    
    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题