AngularJS 与 jQuery 有何不同 [英] How is AngularJS different from jQuery

查看:36
本文介绍了AngularJS 与 jQuery 有何不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只知道一个 js 库,那就是 jQuery.
但是我组中的其他编码人员正在将 AngularJS 更改为他们在新项目中的默认库.

I only know one js library and that is jQuery.
But my other coders in the group are changing AngularJS as their default library in new project.

我对此一无所知.它与 jQuery 有何不同?
我已经为 jQuery 中的类似任务完​​成了一组函数.我还能在 AngularJS 中使用 jQuery 的东西吗?

I don't know anything about it. How is it different from jQuery?
I already have a set of functions done for similar tasks in jQuery. Can I still use jQuery stuff with AngularJS?

推荐答案

  1. Angular 1 是一个框架,而 Angular 2 是一个平台.(ref)

对于开发人员,Angular2 提供了一些功能,而不仅仅是在屏幕上显示数据.例如,使用 angular2 cli 工具可以帮助您预编译"您的代码并生成必要的 javascript 代码(tree-shaking) 将下载大小缩小到 35Kish.

To developers, Angular2 provides some features beyond showing data on screen. For example, using angular2 cli tool can help you "pre-compile" your code and generate necessary javascript code (tree-shaking) to shrink the download size down to 35Kish.

  1. Angular2 模拟了 Shadow DOM.(ref)

这为服务器渲染打开了一扇门,它可以解决 SEO 问题并与无法在浏览器上运行的 Nativescript 等一起使用.

This opens a door for server rendering that can address SEO issue and work with Nativescript etc that don't work on browsers.

2016 年 ng-conf 第一天主题演讲

资源链接原文:基本上,jQuery 是一个很好的工具,可以让您操作和控制 DOM 元素.如果您只关注 DOM 元素而不关注数据 CRUD,例如构建网站而不是 Web 应用程序,那么 jQuery 是顶级工具之一.(您也可以为此目的使用 AngularJS.)

Resource links Original: Basically, jQuery is a great tool for you to manipulate and control DOM elements. If you only focus on DOM elements and no Data CRUD, like building a website not web application, jQuery is the one of the top tools. (You can use AngularJS for this purpose as well.)

AngularJS 是一个框架.它有以下特点

AngularJS is a framework. It has following features

  1. 双向数据绑定
  2. MVW 模式(MVC 风格)
  3. 模板
  4. 自定义指令(可重用组件、自定义标记)
  5. REST 友好
  6. 深层链接(为任何动态页面设置链接)
  7. 表单验证
  8. 服务器通信
  9. 本地化
  10. 依赖注入
  11. 完整的测试环境(两个单元,e2e)

检查这个 presentation 和这个 精彩介绍

check this presentation and this great introduction

不要忘记阅读官方开发者指南

或者从这些很棒的视频教程

如果您想观看更多教程视频,请查看此帖子,最好的 60 多个 AngularJS 教程合集.

If you want to watch more tutorial video, check out this post, Collection of best 60+ AngularJS tutorials.

您可以毫无问题地将 jQuery 与 AngularJS 结合使用.

You can use jQuery with AngularJS without any issue.

事实上,AngularJS 在其中使用了 jQuery lite,这是一个很棒的工具.

In fact, AngularJS uses jQuery lite in it, which is a great tool.

来自常见问题

Angular 是否使用 jQuery 库?

Does Angular use the jQuery library?

是的,如果 jQuery 出现在您的应用程序中,Angular 可以使用它应用程序正在被引导.如果 jQuery 不存在于您的脚本路径,Angular 回退到它自己的实现我们称为 jQLite 的 jQuery 子集.

Yes, Angular can use jQuery if it's present in your app when the application is being bootstrapped. If jQuery is not present in your script path, Angular falls back to its own implementation of the subset of jQuery that we call jQLite.

但是,不要尝试使用 jQuery 来修改 AngularJS 控制器中的 DOM,而是在您的指令中进行.

However, don't try to use jQuery to modify the DOM in AngularJS controllers, do it in your directives.

更新:

Angular2 发布.这里是一个很好的初学者资源列表

Angular2 is released. Here is a great list of resource for starters

这篇关于AngularJS 与 jQuery 有何不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆