我只知道一个js库,那就是jQuery。 但我在组中的其他程序员正在改变AngularJS作为他们在新项目的默认库。
我什么都不知道。它与jQuery有什么不同? 我已经在jQuery中为类似的任务做了一组函数。我还能在AngularJS中使用jQuery的东西吗?
我只知道一个js库,那就是jQuery。 但我在组中的其他程序员正在改变AngularJS作为他们在新项目的默认库。
我什么都不知道。它与jQuery有什么不同? 我已经在jQuery中为类似的任务做了一组函数。我还能在AngularJS中使用jQuery的东西吗?
当前回答
Jquery: -
jQuery is a lightweight and feature-rich JavaScript Library that helps web developers
by simplifying the usage of client-side scripting for web applications using JavaScript.
It extensively simplifies using JavaScript on a website and it’s lightweight as well as fast.
So, using jQuery, we can:
easily manipulate the contents of a webpage
apply styles to make UI more attractive
easy DOM traversal
effects and animation
simple to make AJAX calls and
utilities and much more…
AngularJS: -
AngularJS is a product by none other the Search Engine Giant Google and it’s an open source
MVC-based framework(considered to be the best and only next generation framework). AngularJS
is a great tool for building highly rich client-side web applications.
As being a framework, it dictates us to follow some rules and a structured approach. It’s
not just a JavaScript library but a framework that is perfectly designed (framework tools
are designed to work together in a truly interconnected way).
In comparison of features jQuery Vs AngularJS, AngularJS simply offers more features:
Two-Way data binding
REST friendly
MVC-based Pattern
Deep Linking
Template
Form Validation
Dependency Injection
Localization
Full Testing Environment
Server Communication
其他回答
Angular 1是一个框架,而Angular 2是一个平台。(ref)
对于开发者来说,Angular2除了在屏幕上显示数据之外,还提供了一些其他的特性。例如,使用angular2 cli工具可以帮助你“预编译”你的代码,并生成必要的javascript代码(摇树),将下载大小缩小到35Kish。
Angular2模拟Shadow DOM。(ref)
这为服务器渲染打开了一扇门,可以解决SEO问题,并与不能在浏览器上工作的Nativescript等一起工作。
官方文件网站 ng-conf 2016的第一天主题演讲 资源链接 原: 基本上,jQuery是操作和控制DOM元素的好工具。 如果你只关注DOM元素,而不关注Data CRUD,比如构建一个网站而不是web应用程序,jQuery是最好的工具之一。(你也可以使用AngularJS来实现这个目的。)
AngularJS是一个框架。它有以下特点
双向数据绑定 MVW模式(近似mvc) 模板 定制指令(可重用组件,定制标记) REST-friendly 深度链接(为任何动态页面设置链接) 表单验证 服务器通信 本地化 依赖注入 完整的测试环境(包括单元、端到端)
看看这个演示和这个很棒的介绍
别忘了阅读官方开发者指南
或者从这些很棒的视频教程中学习
如果你想看更多的教程视频,看看这个帖子,收集最好的60+ AngularJS教程。
你可以在AngularJS中使用jQuery,没有任何问题。
事实上,AngularJS使用了jQuery lite,这是一个很棒的工具。
从常见问题解答
Angular使用jQuery库吗? 是的,Angular可以使用jQuery,如果它出现在你的应用中 应用程序正在引导。如果jQuery没有出现在您的 脚本路径,Angular就会退回到它自己的 jQuery的子集,我们称之为jQLite。
但是,不要尝试使用jQuery来修改AngularJS控制器中的DOM,在你的指令中做。
更新:
Angular2被释放。这里有一个很好的资源列表,适合初学者
Jquery: -
jQuery is a lightweight and feature-rich JavaScript Library that helps web developers
by simplifying the usage of client-side scripting for web applications using JavaScript.
It extensively simplifies using JavaScript on a website and it’s lightweight as well as fast.
So, using jQuery, we can:
easily manipulate the contents of a webpage
apply styles to make UI more attractive
easy DOM traversal
effects and animation
simple to make AJAX calls and
utilities and much more…
AngularJS: -
AngularJS is a product by none other the Search Engine Giant Google and it’s an open source
MVC-based framework(considered to be the best and only next generation framework). AngularJS
is a great tool for building highly rich client-side web applications.
As being a framework, it dictates us to follow some rules and a structured approach. It’s
not just a JavaScript library but a framework that is perfectly designed (framework tools
are designed to work together in a truly interconnected way).
In comparison of features jQuery Vs AngularJS, AngularJS simply offers more features:
Two-Way data binding
REST friendly
MVC-based Pattern
Deep Linking
Template
Form Validation
Dependency Injection
Localization
Full Testing Environment
Server Communication
他们在不同的层次上工作。
从初学者的角度来看,最简单的区别是jQuery本质上是JavaScript的抽象,所以我们为JavaScript设计页面的方式几乎就是我们为jQuery设计页面的方式。从DOM开始,然后在此基础上构建一个行为层。而Angular.Js则不是这样。这个过程实际上是从头开始的,所以最终的结果是理想的视图。
用jQuery可以做dom操作,用Angular.Js可以创建整个web应用程序。
jQuery的构建是为了抽象出各种浏览器特性,并且无需添加IE6检查等就可以使用DOM。随着时间的推移,它开发了一个不错的、健壮的API,允许我们做很多事情,但它的核心是用于处理DOM、查找元素、更改UI等等。把它想象成直接用螺母和螺栓工作。
js是建立在jQuery之上的一个层,用于将MVC概念添加到前端工程中。Angular.Js没有为你提供api来使用DOM,而是为你提供了数据绑定、模板、自定义组件(类似于jQuery UI,但是声明式的,而不是通过JS触发)以及很多其他功能。可以把它看作是在更高的级别上工作,使用可以连接在一起的组件,而不是直接在螺母和螺栓级别上工作。
此外,Angular.Js还提供了应用于各种项目的结构和概念,比如控制器、服务和指令。jQuery本身可以以多种(无数)方式来完成相同的事情。值得庆幸的是,在Angular.Js中,这种情况要少得多,这使得进入和退出项目变得更容易。它为多人为同一个项目做出贡献提供了一种明智的方式,而不必从头开始重新学习一个系统。
一个简短的比较可以是这样的-
jQuery
Can be easily used by those who have proper knowledge on CSS selectors It is a library used for DOM Manipulations Has nothing to do with models Easily manipulate the contents of a webpage Apply styles to make UI more attractive Easy DOM traversal Effects and animation Simple to make AJAX calls and Utilities usability don't have a two-way binding feature becomes complex and difficult to maintain when the size of a project increases Sometimes you have to write more code to achieve the same functionality as in Angular.Js
Angular.Js
它是一个MVVM框架 用于创建SPA(单页应用程序) 它具有路由、指令、双向数据绑定、模型、依赖注入、单元测试等关键特性 是模块化 可维护的,当项目规模增加时 快 双向数据绑定 其他友好 基于mvc模式 深度链接 模板 内置表单验证 依赖注入 本地化 完整测试环境 服务器通信
还有更多
我想这有帮助。
更多的可以发现-
jQuery与AngularJS:比较和迁移演练 “用AngularJS思考”,如果我有jQuery背景? jQuery和AngularJS之间的主要区别是什么? jQuery Vs AngularJS -一个很好的对比 jQuery和AngularJS的区别是什么?
AngularJS: AngularJS是用于开发重型web应用程序的。当应用程序启动时,AngularJS可以使用jQuery,如果jQuery出现在web应用程序中。如果它没有出现在脚本路径中,那么AngularJS就会退回到它自己的jQuery子集实现。
JQuery: jQuery是一个小型、快速且功能丰富的JavaScript库。它使HTML文档遍历和操作、事件处理、动画和Ajax等事情变得更加简单。jQuery简化了JavaScript中很多复杂的东西,比如AJAX调用和DOM操作。
阅读更多细节:angularjs-vs-jquery
我认为这张图表很好地描述了两者的差异。快速浏览一下就会发现大部分的不同之处。
我想补充的一点是,AngularJS可以遵循MVVM设计模式,而jQuery不遵循任何标准的面向对象模式。