47

I was reading that AngularJS comes with a lite version of jQuery. However I keep hearing reference to people who talk about Angular and jQuery going together. I even checked out ng-grid and noticed that it says:

Angular Data Grid written in AngularJS and jQuery by the AngularUI Team

So if I do use Angular just when would I need jQuery and what does the version that comes as part of AngularJS not provide?

4

1 回答 1

74

jQLite is a very stripped-down version of jQuery. jQLite is enough for angular to work. This is to minimize dependencies.

Yet, if you load jQuery before angular, then angular will use jQuery.

大多数时候,您不需要使用 jQuery。即便如此,对于初学者来说,还是建议完全放弃 jQuery,因为当有一种简单/有角度的方式时,就会倾向于使用 jQuery。这方面有很多例子(主要是通过 jQuery 显示和隐藏元素,当有ngShowngHide指令时)。

稍后,当您开始编写指令时,您可能需要添加 jQuery。

ngGrid可能会做很多jqLite做不到的事情。因此,他们使用了jQuery.

jqLit​​e 的文档和功能:http: //docs.angularjs.org/api/angular.element

于 2013-03-31T00:23:02.773 回答