search

Home  >  Q&A  >  body text

angular.js - How to use jquery and other plug-ins in angular2?

How to use jquery and other plug-ins in angular2
For example:
class MyComponent {

constructor() {
    // how to query the DOM element from here?
}

}
Although I have read a few answers, I don’t understand them, and I have failed to try them myself. Please give me some advice

PHP中文网PHP中文网2798 days ago857

reply all(3)I'll reply

  • 某草草

    某草草2017-05-15 17:10:46

    First install jquery

    tsd install jquery --save
    

    or

    typings install dt~jquery --global --save
    
    

    Write in the header of the ts file you need to use

    declare var $: any;
    
    

    This way you can use jquery in your ts file

    reply
    0
  • 黄舟

    黄舟2017-05-15 17:10:46

    Like it, but it is not recommended to use Jquery in angular2, it is easy to be contaminated

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-15 17:10:46

    ng2 Don’t use jquery, there is no need
    If you pass the dom, just specify it #content in the template

    reply
    0
  • Cancelreply