简体   繁体   中英

Is it good to use jQuery with angular 2+

While searching for "showing bootsrap modal in angular 2" I encountered following answer: https://stackoverflow.com/a/38271918/1291122

It simply declares jQuery as this:

declare var jQuery:any;

And uses it to show/hide modal like this:

jQuery("#myModal").modal("hide");

This was the shortest way to achieve what I need in angular 2(other all answers seemed to make it fairly complex equivalent to rocket science!)

While this is the shortest way, is it the recommended way to do it? And in general is it a good idea to use jQuery with angular 2+?

EDIT:

My question is different from How to use jQuery with Angular2? Because I am asking WHETHER (or not) to use jQuery with angular 2, while that question is about HOW to use jquery with angular 2. I already know and have mentioned How to do it.

Yes you can use it without any problem.

This is the fastest solution, but you can have an even better one in this topic . Basically, it gives a way to have all the methods with the IDE auto complete.

I don't see a downside. Especially in cases where you use external libraries. However, just don't revert to Jquery trying to solve angular problems like templating etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM