更新记录

The Angular documentation is a living document with continuous improvements. This log calls attention to recent significant changes.

我们将持续不断的更新和改进Angular文档。本日志记录了近期最重要的变更。

Updated to Angular 4.0. Documentation for Angular 2.x can be found at v2.angular.io.

更新到 Angular 4.0 。Angular 2.x 的文档在 v2.angular.io

All mention of moduleId removed. "Component relative paths" cookbook deleted (2017-03-13)

移除了所有的moduleId引用。移除了“组件相对路径” 的烹饪书。(2017-03-13)

We added a new SystemJS plugin (systemjs-angular-loader.js) to our recommended SystemJS configuration. This plugin dynamically converts "component-relative" paths in templateUrl and styleUrls to "absolute paths" for you.

我们往建议的SystemJS配置中新增了一个SystemJS插件 (systemjs-angular-loader.js) 。 这个插件可以帮你把templateUrl和styleUrls中的组件相对路径动态转换为绝对路径。

We strongly encourage you to only write component-relative paths. That is the only form of URL discussed in these docs. You no longer need to write @Component({ moduleId: module.id }), nor should you.

我们强烈建议你只写组件相对路径。 这也是本文档中所使用的唯一形式。你不必再写@Component({ moduleId: module.id }),而且也不应该再这么写。

NEW: Downloadable examples for each guide (2017-02-28)

新增:每篇指南都增加了可下载的范例程序 (2017-02-28)

Now you can download the sample code for any guide and run it locally. Look for the new download links next to the "live example" links.

现在你可以为任何一篇指南下载范例程序,并且在本地运行它了。 请在“在线例子”的链接后面查找新的下载链接。

Template Syntax/Structural Directives: refreshed (2017-02-06)

模板语法/结构型指令:更新了 (2017-02-06)

The Template-Syntax and Structural Directives guides were significantly revised for clarity, accuracy, and current recommended practices. Discusses <ng-container>. Revised samples are more clear and cover all topics discussed.

模板语法结构型指令这两篇指南做了大幅修改,来让它们更加清晰、准确,并符合当前的最佳实践。 讨论了<ng-container>。 修改了例子,来让它们更清晰,并且覆盖了所有讨论到的主题。

NEW: Samples re-structured with src/ folder (2017-02-02)

新增:调整了范例程序的结构,移到了src/文件夹 (2017-02-02)

All documentation samples have been realigned with the default folder structure of the Angular CLI. That's a step along the road to basing the sample in the Angular CLI. But it's also good in its own right. It helps clearly separate app code from setup and configuration files.

所有的文档范例都已经向Angular CLI的默认文件夹结构看齐了。 这是把范例迁移到Angular CLI过程中的一步。 不过也不仅是为了迁移,它确实能帮我们把应用代码从环境代码和配置代码中分离出来。

All samples now have a src/ folder at the project root. The former app/ folder moves under src/. Read about moving your existing project to this structure in the QuickStart repo update instructions.

我们已经把所有范例改成了使用项目根目录下的src/文件夹。 也就是把以前的app/文件夹移到了src/文件夹下面。 要了解如何对你的现有工程进行这种迁移,请参阅QuickStart中的迁移指南

Notably:

要点:

NEW: Reactive Forms guide (2017-01-31)

新增:响应式(Reactive)表单指南 (2017-01-31)

The new Reactive Forms guide explains how and why to build a "reactive form". "Reactive Forms" are the code-based counterpart to the declarative "Template Driven" forms approach introduced in the Forms guide. Check it out before you decide how to add forms to your app. Remember also that you can use both techniques in the same app, choosing the approach that best fits each scenario.

新的响应式表单指南解释了如何以及何时构建“响应式表单”。 “响应式表单”是基于代码的表单构建方式,与表单中介绍的声明“模板驱动”表单的方法相对。 在你决定如何往应用中添加表单之前,建议先读读那一章。 同时,别忘了你可以在同一个应用中同时使用这两种技术,根据场景来选择最合适的方法。

NEW: Deployment guide (2017-01-30)

新增:部署指南 (2017-01-30)

The new Deployment guide describes techniques for putting your application on a server. It includes important advice on optimizing for production.

新的部署指南讲的是如何把应用放到服务器上。 其中包括了为生产环境进行优化的重要建议。

Hierarchical Dependency Injection: refreshed (2017-01-13)

多级依赖注入:更新完毕 (2017-01-13)

Hierarchical Dependency Injection guide is significantly revised. Closes issue #3086. Revised samples are clearer and cover all topics discussed

多级依赖注入做了显著修改。关闭了issue #3086。修改过的范例更加清晰,而且覆盖了讨论到的全部主题。

Miscellaneous (2017-01-05)

杂项 (2017-01-05)

Router: more detail (2016-12-21)

路由:更详细 (2016-12-21)

Added more information to the Router guide including sections named outlets, wildcard routes, and preload strategies.

路由指南中添加了更多信息,包括“命名出口(Outlet)”、通配符路由和预加载策略。

HTTP: how to set default request headers (and other request options) (2016-12-14)

Http:如何设置默认的请求头(以及其它配置项) (2016-12-14)

Added section on how to set default request headers (and other request options) to HTTP guide.

Http指南中添加了一节“如何设置默认的请求头(以及其它配置项)”

Testing: added component test plunkers (2016-12-02)

测试:添加了组件测试的plunker范例 (2016-12-02)

Added two plunkers that each test one simple component so you can write a component test plunker of your own: one for the QuickStart seed's AppComponent and another for the Testing guide's BannerComponent. Linked to these plunkers in Testing and Setup anatomy guides.

添加了两个plunker例子,每个都测试一个简单的组件,以便你可以自己在plunker中写组件测试:一个用于测试快速起步中的AppComponent另一个用于测试“测试”章节的BannerComponent。 并在测试环境设置剖析中链接到它们。

Internationalization: pluralization and select (2016-11-30)

国际化:单复数和select (2016-11-30)

The Internationalization (i18n) guide explains how to handle pluralization and translation of alternative texts with select. The sample demonstrates these features too.

国际化 (i18n)解释了如何处理单复数问题,和如何使用select来翻译候选内容。 例子中也演示了这些特性。

Testing: karma file updates (2016-11-30)

测试:更新了karma文件 (2016-11-30)

QuickStart Rewrite (2016-11-18)

全新《快速起步》 (2016-11-18)

The QuickStart is completely rewritten so that it actually is quick. It references a minimal "Hello Angular" app running in Plunker. The new Setup page tells you how to install a local development environment by downloading (or cloning) the QuickStart github repository. You are no longer asked to copy-and-paste code into setup files that were not explained anyway.

完全重写了《快速起步》,变得更加快速。 它使用了在 Plunker 中运行的最小化的 “Hello Angular” 应用。 新添加的搭建本地开发环境页面解释了如何通过下载或者克隆 QuickStart github 库来安装本地开发环境。 你将不再需要拷贝粘贴代码到一些并没有对其解释的配置文件中。

Sync with Angular v.2.2.0 (2016-11-14)

与Angular v.2.2.0同步(2016-11-14)

Docs and code samples updated and tested with Angular v.2.2.0 .

使用Angular v.2.2.0更新和测试所有文档和代码例子。

UPDATE: NgUpgrade Guide for the AOT friendly upgrade/static module (2016-11-14)

更新:用于AoT的upgrade/static模块NgUpgrade指南 (2016-11-14)

The updated NgUpgrade Guide guide covers the new AOT friendly upgrade/static module released in v.2.2.0, which is the recommended facility for migrating from AngularJS to Angular. The documentation for the version prior to v.2.2.0 has been removed.

更新的NgUpgrade指南覆盖在v.2.2.0发布的AoTupgrade/static模块, 是从AngularJS升级至Angular的推荐工具。 删除早于v.2.2.0版本的文档。

ES6 described in "TypeScript to JavaScript" (2016-11-14)

在“从TypeScript到JavaScript”增加ES6的描述 (2016-11-14)

The updated TypeScript to JavaScript cookbook now explains how to write apps in ES6/7

更新了“从TypeScript到JavaScript”烹饪宝典,解释如何使用ES6/7编写应用

by translating the common idioms in the TypeScript documentation examples (and elsewhere on the web) to ES6/7 and ES5.

将TypeScript文档示例中(以及网站其它地方)的习惯用法翻译成ES6/7和ES5。

Sync with Angular v.2.1.1 (2016-10-21)

与Angular v.2.1.1 同步(2016-10-21)

Docs and code samples updated and tested with Angular v.2.1.1.

使用Angular v.2.1.1更新和测试所有文档和代码例子。

npm @types packages replace typings (2016-10-20)

使用npm的@types包替换typings (2016-10-20)

Documentation samples now get TypeScript type information for 3rd party libraries from npm @types packages rather than with the typings tooling. The typings.json file is gone.

文档例子现在从npm的@types第三方库获取TypeScript类型信息,不再使用typings。 删除typings.json文件。

The AngularJS Upgrade guide reflects this change. The package.json installs @types/angular and several @types/angular-... packages in support of upgrade; these are not needed for pure Angular development.

"从AngularJS升级"指南反映了这个变化。 package.json安装@types/angular和一些@types/angular-...包来支持升级。它们在纯Angular开发中是不需要的。

"Template Syntax" explains two-way data binding syntax (2016-10-20)

"模板语法"添加了双向数据绑定语法的解释(2016-10-20)

Demonstrates how to two-way data bind to a custom Angular component and re-explains [(ngModel)] in terms of the basic [()] syntax.

展示了如何在自定义Angular组件中双向数据绑定,用基础[()]重新解释[(ngModel)]

BREAKING CHANGE: in-memory-web-api (v.0.1.11) delivered as esm umd (2016-10-19)

破坏性变化:in-memory-web-api (v.0.1.11) 以esm umd的形式发布 (2016-10-19)

This change supports ES6 developers and aligns better with typical Angular libraries. It does not affect the module's API but it does affect how you load and import it. See the change note in the in-memory-web-api repo.

这个变化支持ES6开发者,并与典型的Angular库看齐。 它不会影响模块的API,但是它改变了加载和导入它的方式。 参见in-memory-web-api库的变更记录

"Router" preload syntax and :enter/:leave animations (2016-10-19)

"路由器"预加载语法和:enter/:leave动画(2016-10-19)

The router can lazily preload modules after the app starts and before the user navigates to them for improved perceived performance.

路由器可以在应用启动之后和用户导航到惰性加载模块之前,预先加载惰性模块,以增强性能。

New :enter and :leave aliases make animation more natural.

:enter:leave语法,让动画更加自然。

Sync with Angular v.2.1.0 (2016-10-12)

与Angular v.2.1.0同步(2016-10-12)

Docs and code samples updated and tested with Angular v.2.1.0 .

使用Angular v.2.1.0更新和测试所有文档和代码例子。

NEW "Ahead of time (AOT) Compilation" cookbook (2016-10-11)

添加了新的“预编译(AoT)"烹饪书(2016-10-11)

The NEW Ahead of time (AOT) Compilation cookbook explains what AOT compilation is and why you'd want it. It demonstrates the basics with a QuickStart app followed by the more advanced considerations of compiling and bundling the Tour of Heroes.

全新预编译(AoT)烹饪书介绍了什么是AoT编译和为何你需要它。 它以快速起步应用程序开始讲解,接着介绍了编译和构建英雄指南的更高级的注意事项。

Sync with Angular v.2.0.2 (2016-10-6)

与Angular v.2.0.2同步 (2016-10-6)

Docs and code samples updated and tested with Angular v.2.0.2 .

使用Angular v.2.0.2更新和测试所有文档和代码例子。

"Routing and Navigation" guide with the Router Module (2016-10-5)

在“路由和导航”向导中添加路由模块 (2016-10-5)

The Routing and Navigation guide now locates route configuration in a Routing Module. The Routing Module replaces the previous routing object involving the ModuleWithProviders.

Routing and Navigation现在在路由模块中设置路由配置。 路由模块替换之前的路由对象,使用了ModuleWithProviders

Routing and Navigation

路由与导航

All guided samples with routing use the Routing Module and prose content has been updated, most conspicuously in the NgModule guide and NgModule FAQ cookbook.

所有使用路由的例子都使用路由模块,相关内容也被更新。更新最多的是Angular模块(NgModule)章和Angular模块常见问题烹饪书。

New "Internationalization" Cookbook (2016-09-30)

全新“国际化”烹饪书(2016-09-30)

Added a new Internationalization (i18n) cookbook that shows how to use Angular "i18n" facilities to translate template text into multiple languages.

添加了新的国际化(i18n)烹饪书,展示了如何使用Angular的“i18n”工具来讲模板文本翻译到多种语言。

"angular-in-memory-web-api" package rename (2016-09-27)

重命名“angular-in-memory-web-api”包(2016-09-27)

Many samples use the angular-in-memory-web-api to simulate a remote server. This library is also useful to you during early development before you have a server to talk to.

许多例子使用了angular-in-memory-web-api来模拟远程服务器。 这个库在你拥有服务器之前的早期开发阶段也很有用。

The package name was changed from "angular2-in-memory-web-api" which is still frozen-in-time on npm. The new "angular-in-memory-web-api" has new features. Read about them on github.

这个包的名字从“angular2-in-memory-web-api”(仍然有效,但不再更新了)重新命名了。 新的“angular-in-memory-web-api”有新的功能。 到github获得更多详情.

"Style Guide" with NgModules (2016-09-27)

“风格指南”中添加了NgModules(2016-09-27)

StyleGuide explains recommended conventions for Angular modules (NgModule).

StyleGuide解释了我们为Angular模块(NgModule)而推荐的约定。

Barrels now are far less useful and have been removed from the style guide; they remain valuable but are not a matter of Angular style. Also relaxed the rule that discouraged use of the @Component.host property.

现在,封装桶不再那么重要,风格指南已经移除了它们。 它们仍然很有价值,但是它们与Angular风格无关。 我们同时对不推荐使用@Component.host属性的规则有所放宽。

moduleId: module.id everywhere (2016-09-25)

moduleId:到处添加module.id(2016-09-25)

Sample components that get their templates or styles with templateUrl or styleUrls have been converted to module-relative URLs. Added the moduleId: module.id property-and-value to their @Component metadata.

在所有使用templateUrl或者styleUrls来获取模板或样式的例子组件都被转换为相对模块的URL。 我们添加了moduleId: module.id到它们的@Component元数据。

This change is a requirement for compilation with AOT compiler when the app loads modules with SystemJS as the samples currently do.

当应用像例子当前使用的方法一样 - 使用SystemJS加载模块时,本更新是AoT编译器的前提条件。

"Lifecycle Hooks" guide simplified (2016-09-24)

简化了“生命周期钩子”章(2016-09-24)

The Lifecycle Hooks guide is shorter, simpler, and draws more attention to the order in which Angular calls the hooks.

生命周期钩子章现在更加简短,并且对强调了Angular是以什么顺序来调用钩子方法的。