I know Angular2 's idea of using jquery might see a little bit of an odd lot of you, and we all know that ANGULAR2 is responsible for managing everything related to our view components and DOM elements, which sounds like a good idea, and a working corner made with another frame can be easily done.
In other words, why would anyone want jquery and ANGULAR2 integration?
Well, there are cases where we still have to use jquery, like reusing some jquery code or component, it's impossible to rewrite everything with angular2, which is probably why you're reading this tutorial.
Now let's see how to do this, in fact it's really simple, basically all you have to do is add jquery script to your index.html and component declaration jquery, here's an example:
Import {Component} from 'Angular2/core'; declarevarJquery:any; @Component ({selector:'My-app', Template: '<button onclick="console.log (' It worked!! ')">JQuery Integration Test</button> `}) ExportclassAppComponent {ngafterviewinit () {JQuery ('Button'). Click (); }}
When you run your application, you will see the text of it working! "On your console. That's what happened! This is a very short tutorial, but I hope it will help you.
Using jquery in Angular2