在角JS项目使用jQuery这种好的做法呢?做法、项目、JS、jQuery

2023-09-13 03:20:16 作者:乖一点就抱你

我是新来的角JS。我需要开发项目采用了棱角分明的JS,HTML5。

I am new to Angular JS. I need to develop project using Angular JS, HTML5.

有关在previous项目DOM操作我已经使用jQuery框架。现在我很困惑的是角JS项目使用jQuery这个好方法。因为许多的jQuery的功能已经可用具有角的js即jQLite但有一些限制。

For DOM manipulation in previous project i have used jQuery framework. Now I am confused that is this good approach to use jQuery in Angular JS project. Because many of the functions of jQuery are already available with angular js i.e. jQLite but with some limitations.

我也问过很多人,但也没有人回答我非常满意,有的说没有,有的说是的。

I have asked many people also but no one's answer satisfied me, some say no and some say yes.

请帮助我在此话题。我有搜索的计算器也,但没有运气这个问题。我认为这将是对其他开发商也谁是新的角度JS和想用角JS来开发应用程序非常有用。

Please help me on this topic. I have search this question on stackoverflow also but no luck. I think it will be useful for other developers also who are new to Angular JS and want to develop application using Angular JS.

推荐答案

你应该做的第一件事就是阅读SO此线程"Thinking在AngularJS"如果我有一个jQuery的背景是什么?。这会给你一些观点。

The first thing you should do is to read this thread on SO "Thinking in AngularJS" if I have a jQuery background?. This will give you some perspective.

当它涉及到驱动的观点和时代最直接的DOM操作不是必需的角度,它的型号。

When it comes to Angular, it the model that drives the view and most of the times direct DOM manipulation is not required.

有关,如果你使用的是DOM操作,显示\\隐藏元素,添加删除类或设置样式的例子,那么最好使用 NG-展示\\纳克级\\ NG式指令

For example if you are using DOM manipulation to show\hide element, add remove class or set style, then better to use ng-show\ng-class\ng-style directive.

但也有当需要DOM操作,这是你写的指令,要么使用jqLit​​e或jQuery来操作DOM时的情况。

But there are cases when DOM manipulation is required and that is the time you write directives and either use jqLite or jQuery to manipulate DOM.

我的建议是,以避免jQuery的,除非你有合并一个jQuery插件是依赖于jQuery的。

My suggestion would be to avoid jQuery unless you have to incorporate a jquery plugin that is dependent on jQuery.

在开发一直看,如果内置的指令,它们可以为你的目的。如果没有可jqLit​​e用于实现所期望的那样。你最后的解决办法应该是jQuery的。

While developing always look if the inbuilt directives that can serve your purpose. If not can jqLite be used to achieve what is desired. Your final resort should be jQuery.