how to use jquery in angular 2?

前端 未结 2 1861
北恋
北恋 2021-01-20 23:06

I know if i I need to use 3rd party library in angular 1.3 or 1.4 .I need to make directive of that thing and use that in our project .Now I am using angular 2.0

2条回答
  •  无人共我
    2021-01-20 23:58

    You just need to declare one variable and put values or initilize that variable with the values that your required. in the constructor you have to define Jquery part . take a look at this.Here is working example for Autocomplete which is required to you

    http://plnkr.co/edit/dAMQc0EN6rSS4dEuTR7E?p=preview

    Just put this code into the constructor :

    export class AppComponent { 
      availableTags = [
          "ActionScript",
          "AppleScript",
          "Asp",
          "BASIC",...
        ];
      constructor(){
        $( "#tags" ).autocomplete({
          source: this.availableTags
        });
      }
    }
    

提交回复
热议问题