问题描述
现在,我花一段时间与Twitter的引导播放后服用看看Angularjs。我真的很喜欢举,因为它很容易,时尚,非常适合移动设备。现在angularjs,我看到人们推荐它代替的jQuery和说,只要去,请勿使用jQuery在所有和angularjs所做的一切。
Right now, I am taking a look at Angularjs after spending sometime playing with twitter's bootstrap. I really like bootstrap because it's easy, sleek and very mobile-friendly. Now for angularjs, I see people recommending it instead of Jquery and going as far as in saying that, DO NOT USE JQUERY AT ALL and do everything on angularjs.
这问题和答案帮助塑造我的一些信仰,为什么我应该搬到angularjs比jQuery的。
This question and answers helped to shape some of my beliefs and why I should move to angularjs than jquery.
How我认为AngularJS如果我有一个jQuery的背景是什么?
接受这个问题的答案(这是非常周密细致!)是这样的其整体摘要:
Accepted answer to this question ( which is very well-detailed!) goes like this on its overall summary:
甚至不使用jQuery。甚至不包括它。它会拖你后腿。
而当你来到你想到一个问题,你知道如何解决
已经jQuery的,你达到了$之前,尽量思考如何
做到这一点的框框内AngularJS。如果你不知道,问! 19
超时20,要做就做最好的办法并不需要jQuery和尝试
使用jQuery结果来解决它的更多的工作适合你。
即使从angularjs网站的常见问题解答说,不要用它。
Even the FAQs from angularjs website says not to use it Angularjs FAQs.
DOM操作
停止尝试使用jQuery修改DOM中
控制器。真。这包括添加元素,删除元素,
检索的内容,显示和隐藏它们。使用内置
指令,或写自己在必要时,做你的DOM
操纵。可以看看下面的复制功能。
如果您有困难,打破习惯,考虑删除的jQuery
您的应用程序。真。角有$ http服务和强大的
指令,使得它几乎总是不必要的。角的捆绑
jQLite具有书面最常使用的特征的少数
角指令,特别是结合事件。
If you're struggling to break the habit, consider removing jQuery from your app. Really. Angular has the $http service and powerful directives that make it almost always unnecessary. Angular's bundled jQLite has a handful of the features most commonly used in writing Angular directives, especially binding to events.
angularjs的概念似乎很诱人。事实上,谁也不会喜欢抽象掉DOM操作逻辑是什么?然而,自举使得它这么多容易,当你在设计网页的网页,但由于引导使用jQuery,引导和angularjs在一起意味着code和整体网页仍然依赖jQuery的。这是完全搅拌机不可取?如果是这样的话,是什么让挂在使用angularjs来引导的最佳方式?简单地说,我没有那么在乎jQuery的,但我喜欢的引导。
The concept of angularjs seems tempting. In fact, who would not like abstracting away DOM manipulation logic? However, bootstrap makes it so much easy when you are designing web-pages but since bootstrap uses jquery, bootstrap and angularjs together means that the code and overall web-page is still dependent on jquery. Is this mixer completely undesirable? If so then, what is the best way to keep hanging to bootstrap while using angularjs? Simply saying, I don't care so much about jquery but I like bootstrap.
我可能会在圈子在这里说话,所以我会尝试改写我所说的一句话。
I might be talking in circles here so I will try to reword what I am saying in a single sentence.
的什么是使用angularjs,并不会产生面条code一起引导其中一个地方是旁边angularjs基于这样基于jQuery的呢?还是用引导的理念和angularjs一起在概念上是最好的办法反对什么angularjs是为那些?的
推荐答案
在试图jQuery的事情来整合角度,最好的办法是把它包起来的指令。这是的本来,但最近的版本升级到2.0完全删除这些依赖并且所有这一切在角(并且它是具有这样做的一个更好的产物。)这是相同的方法,该方法 1天了,并且一直持续到今天。
When trying to integrate jQuery things in to Angular, the best approach is to wrap it in a directive. This is what Angular-Strap originally did, but the recent version upgrade to 2.0 completely removed those dependencies and does it all in Angular (and it is a much better product for having done so.) This is the same method that Angular-UI took from day 1 and that continues today.
当你做这样的事情,最大的障碍是试图让事情变得角化与DOM时。如果你看一下下面的code两个角带和角度的UI可以提供的例子非常好,应该给你正确的方向。
When you do something like this, the biggest hurdle is trying to keep things "Angular-ized" when working with the DOM. The examples that both Angular-Strap and Angular-UI can provide if you look at the underlying code are very good and should give you the right direction.
这篇关于合理的方法来使用引导程序和angularjs在一起而不依赖于jQuery的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!