Sometimes, we want to use jQuery Plugin with Angular.
In this article, we’ll look at how to use jQuery Plugin with Angular.
How to use jQuery Plugin with Angular?
To use jQuery Plugin with Angular, we can install the jquery
package with its TypeScript type definitions.
To install them, we run
npm install jquery
npm install -D @types/jquery
Then we use it by writing
import * as $ from "jquery";
//...
export class JqueryComponent implements OnInit {
constructor() {}
ngOnInit() {
$(window).click(() => {
alert("ok");
});
}
}
to import jquery
with
import * as $ from "jquery";
Then we use it with
$(window).click(() => {
alert("ok");
});
Conclusion
To use jQuery Plugin with Angular, we can install the jquery
package with its TypeScript type definitions.