admin管理员组文章数量:1323335
While searching for "showing bootsrap modal in angular 2" I encountered following answer:
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 plex equivalent to rocket science!)
While this is the shortest way, is it the remended 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.
While searching for "showing bootsrap modal in angular 2" I encountered following answer: https://stackoverflow./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 plex equivalent to rocket science!)
While this is the shortest way, is it the remended 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.
Share Improve this question edited Jun 17, 2017 at 0:51 rahulserver asked Jun 16, 2017 at 13:04 rahulserverrahulserver 11.2k27 gold badges94 silver badges173 bronze badges 5- 2 You can use jQuery, but first ask yourself do you really want this? jQuery works with the physical DOM and adds dependency in to your bundle, which makes it heavier (loading longer). – Alexander Surkov Commented Jun 16, 2017 at 13:21
- 1 @AlbertGore yeah thats correct. Angular and jquery are two very different concepts. While jquery manipulates DOM directly, angular is about data bindings etc.. However in scenarios where you can get something done quickly using a jquery library, I think we need to evaluate the trade offs. – rahulserver Commented Jun 16, 2017 at 13:31
- As alternative way, you can use some ready angular2+ ponents for modal window. – Alexander Surkov Commented Jun 16, 2017 at 13:48
- Possible duplicate of How to use jQuery with Angular2? – Daniel Beck Commented Jun 16, 2017 at 14:01
- Suppose I need to query a lot of tags in SVG. Maybe machine-generated SVG even with lots of nodes. So I don't bind but rather query the tags procedurally. It's obvious that Angular's binding does not always fit well, right. And I could use Zepto to spare some kilobytes. – Gherman Commented Sep 22, 2017 at 6:48
2 Answers
Reset to default 4Yes 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 plete.
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.
本文标签: javascriptIs it good to use jQuery with angular 2Stack Overflow
版权声明:本文标题:javascript - Is it good to use jQuery with angular 2+ - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742136214a2422381.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论