diff --git a/aio/content/guide/ajs-quick-reference.md b/aio/content/guide/ajs-quick-reference.md
index 2a928141b4..ba038fbd11 100644
--- a/aio/content/guide/ajs-quick-reference.md
+++ b/aio/content/guide/ajs-quick-reference.md
@@ -62,9 +62,7 @@ The following table lists some of the key AngularJS template features with their
### 绑定/插值表达式
-
Your favorite hero is: {{vm.favoriteHero}}
-
In AngularJS, an expression in curly braces denotes one-way binding.
@@ -118,9 +116,7 @@ The following table lists some of the key AngularJS template features with their
### 过滤器
-
<td>{{movie.title | uppercase}}</td>
-
To filter output in AngularJS templates, use the pipe character (|) and one or more filters.
@@ -165,11 +161,9 @@ The following table lists some of the key AngularJS template features with their
### 局部变量
-
<tr ng-repeat="movie in vm.movies">
<td>{{movie.title}}</td>
</tr>
-
Here, `movie` is a user-defined local variable.
@@ -246,9 +240,7 @@ AngularJS 为模板提供了七十多个内置指令。
### ng-app
-
<body ng-app="movieHunter">
-
The application startup process is called **bootstrapping**.
@@ -295,11 +287,9 @@ AngularJS 为模板提供了七十多个内置指令。
### ng-class
-
<div ng-class="{active: isActive}">
<div ng-class="{active: isActive,
shazam: isImportant}">
-
In AngularJS, the `ng-class` directive includes/excludes CSS classes
@@ -361,10 +351,8 @@ AngularJS 为模板提供了七十多个内置指令。
### ng-click
-
<button ng-click="vm.toggleImage()">
<button ng-click="vm.toggleImage($event)">
-
In AngularJS, the `ng-click` directive allows you to specify custom behavior when an element is clicked.
@@ -433,9 +421,7 @@ AngularJS 为模板提供了七十多个内置指令。
### ng-controller
-
<div ng-controller="MovieListCtrl as vm">
-
In AngularJS, the `ng-controller` directive attaches a controller to the view.
@@ -506,9 +492,7 @@ AngularJS 为模板提供了七十多个内置指令。
### ng-href
-
<a ng-href="{{ angularDocsUrl }}">Angular Docs</a>
-
The `ng-href` directive allows AngularJS to preprocess the `href` property so that it
@@ -522,9 +506,7 @@ AngularJS 为模板提供了七十多个内置指令。
在 AngularJS 中,`ng-href` 通常用来作为导航的一部分,激活一个路由。
-
<a ng-href="#{{ moviesHash }}">Movies</a>
-
Routing is handled differently in Angular.
@@ -574,9 +556,7 @@ AngularJS 为模板提供了七十多个内置指令。
### ng-if
-
<table ng-if="movies.length">
-
In AngularJS, the `ng-if` directive removes or recreates a portion of the DOM,
@@ -623,9 +603,7 @@ AngularJS 为模板提供了七十多个内置指令。
### ng-model
-
<input ng-model="vm.favoriteHero"/>
-
In AngularJS, the `ng-model` directive binds a form control to a property in the controller associated with the template.
@@ -665,9 +643,7 @@ AngularJS 为模板提供了七十多个内置指令。
### ng-repeat
-
<tr ng-repeat="movie in vm.movies">
-
In AngularJS, the `ng-repeat` directive repeats the associated DOM element
@@ -719,11 +695,9 @@ AngularJS 为模板提供了七十多个内置指令。
### ng-show
-
<h3 ng-show="vm.favoriteHero">
Your favorite hero is: {{vm.favoriteHero}}
</h3>
-
In AngularJS, the `ng-show` directive shows or hides the associated DOM element, based on
@@ -776,9 +750,7 @@ AngularJS 为模板提供了七十多个内置指令。
### ng-src
-
<img ng-src="{{movie.imageurl}}">
-
The `ng-src` directive allows AngularJS to preprocess the `src` property so that it
@@ -819,9 +791,7 @@ AngularJS 为模板提供了七十多个内置指令。
### ng-style
-
<div ng-style="{color: colorPreference}">
-
In AngularJS, the `ng-style` directive sets a CSS style on an HTML element
@@ -877,7 +847,6 @@ AngularJS 为模板提供了七十多个内置指令。
### ng-switch
-
<div ng-switch="vm.favoriteHero &&
vm.checkMovieHero(vm.favoriteHero)">
<div ng-switch-when="true">
@@ -890,7 +859,6 @@ AngularJS 为模板提供了七十多个内置指令。
Please enter your favorite hero.
</div>
</div>
-
In AngularJS, the `ng-switch` directive swaps the contents of
@@ -996,9 +964,7 @@ AngularJS 中的很多内置过滤器在 Angular 中都有对应的管道。
### currency
-
<td>{{movie.price | currency}}</td>
-
Formats a number as currency.
@@ -1028,9 +994,7 @@ AngularJS 中的很多内置过滤器在 Angular 中都有对应的管道。
### date
-
<td>{{movie.releaseDate | date}}</td>
-
Formats a date to a string based on the requested format.
@@ -1060,9 +1024,7 @@ AngularJS 中的很多内置过滤器在 Angular 中都有对应的管道。
### filter
-
<tr ng-repeat="movie in movieList | filter: {title:listFilter}">
-
Selects a subset of items from the defined collection, based on the filter criteria.
@@ -1094,9 +1056,7 @@ AngularJS 中的很多内置过滤器在 Angular 中都有对应的管道。
### json
-
<pre>{{movie | json}}</pre>
-
Converts a JavaScript object into a JSON string. This is useful for debugging.
@@ -1126,9 +1086,7 @@ AngularJS 中的很多内置过滤器在 Angular 中都有对应的管道。
### limitTo
-
<tr ng-repeat="movie in movieList | limitTo:2:0">
-
Selects up to the first parameter (2) number of items from the collection
@@ -1164,9 +1122,7 @@ AngularJS 中的很多内置过滤器在 Angular 中都有对应的管道。
### lowercase
-
<div>{{movie.title | lowercase}}</div>
-
Converts the string to lowercase.
@@ -1196,9 +1152,7 @@ AngularJS 中的很多内置过滤器在 Angular 中都有对应的管道。
### number
-
<td>{{movie.starRating | number}}</td>
-
Formats a number as text.
@@ -1236,9 +1190,7 @@ AngularJS 中的很多内置过滤器在 Angular 中都有对应的管道。
### orderBy
-
<tr ng-repeat="movie in movieList | orderBy : 'title'">
-
Displays the collection in the order specified by the expression.
@@ -1322,11 +1274,9 @@ The Angular code is shown using TypeScript.
### IIFE
-
(function () {
...
}());
-
In AngularJS, an immediately invoked function expression (or IIFE) around controller code
@@ -1365,9 +1315,7 @@ The Angular code is shown using TypeScript.
### Angular 模块
-
angular.module("movieHunter", ["ngRoute"]);
-
In AngularJS, an Angular module keeps track of controllers, services, and other code.
@@ -1412,13 +1360,11 @@ The Angular code is shown using TypeScript.
### 控制器注册
-
angular
.module("movieHunter")
.controller("MovieListCtrl",
["movieService",
MovieListCtrl]);
-
AngularJS has code in each controller that looks up an appropriate Angular module
@@ -1470,10 +1416,8 @@ The Angular code is shown using TypeScript.
### 控制器函数
-
function MovieListCtrl(movieService) {
}
-
In AngularJS, you write the code for the model and methods in a controller function.
@@ -1516,11 +1460,9 @@ The Angular code is shown using TypeScript.
### 依赖注入
-
MovieListCtrl.$inject = ['MovieService'];
function MovieListCtrl(movieService) {
}
-
In AngularJS, you pass in any dependencies as controller function arguments.
@@ -1616,9 +1558,7 @@ also encapsulate a style sheet within a specific component.
### Link 标签
-
<link href="styles.css" rel="stylesheet" />
-
AngularJS, uses a `link` tag in the head section of the `index.html` file
diff --git a/aio/content/guide/animations.md b/aio/content/guide/animations.md
index 2ab2abc18e..40f95462f9 100644
--- a/aio/content/guide/animations.md
+++ b/aio/content/guide/animations.md
@@ -291,10 +291,8 @@ These two common animations have their own aliases:
这两个常见的动画有自己的别名:
-
transition(':enter', [ ... ]); // void => *
transition(':leave', [ ... ]); // * => void
-
@@ -562,5 +560,4 @@ The callbacks receive an `AnimationEvent` that contains useful properties such a
Those callbacks will fire whether or not an animation is picked up.
-
无论动画是否实际执行过,那些回调都会触发。
diff --git a/aio/content/guide/aot-compiler.md b/aio/content/guide/aot-compiler.md
index 0471294df9..1da52a6fe4 100644
--- a/aio/content/guide/aot-compiler.md
+++ b/aio/content/guide/aot-compiler.md
@@ -48,10 +48,8 @@ JIT compilation is the default when you run the _build-only_ or the _build-and-s
当你运行 *`build`* 或 *`serve`* 这两个 CLI 命令时 JIT 编译是默认选项:
-
ng build
ng serve
-
{@a compile}
@@ -61,10 +59,8 @@ For AOT compilation, append the `--aot` flags to the _build-only_ or the _build-
要进行 AOT 编译只要给这两个 CLI 命令添加 `--aot` 标志就行了:
-
ng build --aot
ng serve --aot
-
@@ -170,7 +166,7 @@ The option is `false` by default.
这个选项告诉编译器不要生成 `.metadata.json` 文件,它默认是 `false`。
-`.metadata.json` files contain information needed by the template compiler from a `.ts`
+`.metadata.json` files contain infomration needed by the template compiler from a `.ts`
file that is not included in the `.d.ts` file produced by the TypeScript compiler. This information contains,
for example, the content of annotations (such as a component's template) which TypeScript
emits to the `.js` file but not to the `.d.ts` file.
@@ -195,7 +191,6 @@ include a copy of the information that is in the `.metadata.json` file.
This option tells the template compiler to report an error to the `.metadata.json`
file if `"skipMetadataEmit"` is `false` . This option is `false` by default. This should only be used when `"skipMetadataEmit"` is `false` and `"skipTemplateCodeGen"` is `true`.
-
这个选项告诉模板编译器如果 `"skipMetadataEmit"` 为 `false`,那就把错误信息汇报到 `.metadata.json` 中。
只有当 `"skipMetadataEmit"` 为 `false` 且 `"skipTemplateCodeGen"` 为 `true` 时才应该使用这个选项。
@@ -383,21 +378,21 @@ rules.
这是供 `bazel` 构建规则使用的选项,它用于简化 `bazel` 规则跟踪文件依赖的方式。
除了 `bazel` 规则之外不建议使用该选项。
-### *enableIvy*
+ ### *enableIvy*
-Tells the compiler to generate definitions using the Render3 style code generation. This option defaults to `false`.
+ Tells the compiler to generate definitions using the Render3 style code generation. This option defaults to `false`.
-告诉编译器使用 Render3 风格的代码生成器来来生成各种定义。
+ 告诉编译器使用 Render3 风格的代码生成器来来生成各种定义。
该选项默认为 `false`。
-Not all features are supported with this option enabled. It is only supported
-for experimentation and testing of Render3 style code generation.
+ Not all features are supported with this option enabled. It is only supported
+ for experimentation and testing of Render3 style code generation.
-当开启该选项时,有些特性不受支持。它仅仅用来为试验和测试 Render3 风格的代码生成提供支持。
+ 当开启该选项时,有些特性不受支持。它仅仅用来为试验和测试 Render3 风格的代码生成提供支持。
-*Note*: Is it not recommended to use this option as it is not yet feature complete with the Render2 code generation.
+ *Note*: Is it not recommended to use this option as it is not yet feature complete with the Render2 code generation.
-*注意*:不建议使用该选项,因为它在使用 Render2 的代码生成器时还缺少一些特性。
+ *注意*:不建议使用该选项,因为它在使用 Render2 的代码生成器时还缺少一些特性。
## Angular Metadata and AOT
@@ -828,7 +823,7 @@ The compiler only supports metadata for these Angular decorators.
编译器只支持下列 Angular 装饰器的元数据。
-Decorator装饰器 | Module所在模块
+Decorator装饰器 | Module所在模块
------------------|--------------
`Attribute` | `@angular/core`
`Component` | `@angular/core`
@@ -982,18 +977,18 @@ The following are metadata errors you may encounter, with explanations and sugge
你可能遇到一些元数据错误,下面是对它们的解释和纠正建议。
-[Expression form not supported 【不支持此表达式格式】](#expression-form-not-supported)
-[Reference to a local (non-exported) symbol【引用了局部(未导出的)符号】](#reference-to-a-local-symbol)
-[Only initialized variables and constants【只允许初始化过的变量和常量】](#only-initialized-variables)
-[Reference to a non-exported class【引用了未导出的类】](#reference-to-a-non-exported-class)
-[Reference to a non-exported function【引用了未导出的函数】](#reference-to-a-non-exported-function)
-[Function calls are not supported【不支持函数调用】](#function-calls-not-supported)
-[Destructured variable or constant not supported【不支持解构变量或常量】](#destructured-variable-not-supported)
-[Could not resolve type【不能解析此类型】](#could-not-resolve-type)
-[Name expected【期待是名字】](#name-expected)
-[Unsupported enum member name【不支持的枚举成员名】](#unsupported-enum-member-name)
-[Tagged template expressions are not supported【不支持带标签函数的模板表达式】](#tagged-template-expressions-not-supported)
-[Symbol reference expected【期待是符号引用】](#symbol-reference-expected)
+[Expression form not supported【不支持此表达式格式】](#expression-form-not-supported)
+[Reference to a local (non-exported) symbol【引用了局部(未导出的)符号】](#reference-to-a-local-symbol)
+[Only initialized variables and constants【只允许初始化过的变量和常量】](#only-initialized-variables)
+[Reference to a non-exported class【引用了未导出的类】](#reference-to-a-non-exported-class)
+[Reference to a non-exported function【引用了未导出的函数】](#reference-to-a-non-exported-function)
+[Function calls are not supported【不支持函数调用】](#function-calls-not-supported)
+[Destructured variable or constant not supported【不支持解构变量或常量】](#destructured-variable-not-supported)
+[Could not resolve type【不能解析此类型】](#could-not-resolve-type)
+[Name expected【期待是名字】](#name-expected)
+[Unsupported enum member name【不支持的枚举成员名】](#unsupported-enum-member-name)
+[Tagged template expressions are not supported【不支持带标签函数的模板表达式】](#tagged-template-expressions-not-supported)
+[Symbol reference expected【期待是符号引用】](#symbol-reference-expected)
@@ -1383,7 +1378,6 @@ To correct this error, export a function from the module and refer to the functi
要改正这个问题,就要从模块中导出这个函数,并改成在服务提供商的 `useFactory` 中引用该函数。
-
// CORRECTED
import { calculateValue } from './utilities';
@@ -1399,7 +1393,6 @@ export function someValueFactory() {
{ provide: SomeValue, useFactory: someValueFactory }
]
...
-
@@ -1425,7 +1418,6 @@ For example, you cannot write something like this:
比如,你不能这么写:
-
// ERROR
import { configuration } from './configuration';
@@ -1437,7 +1429,6 @@ const {foo, bar} = configuration;
{provide: Bar, useValue: bar},
]
...
-
To correct this error, refer to non-destructured values.
@@ -1445,7 +1436,6 @@ To correct this error, refer to non-destructured values.
要纠正这个错误,就要引用非解构方式的变量。
-
// CORRECTED
import { configuration } from './configuration';
...
@@ -1454,7 +1444,6 @@ import { configuration } from './configuration';
{provide: Bar, useValue: configuration.bar},
]
...
-
@@ -1528,7 +1517,6 @@ Here's an illustrative example.
下面的例子说明了这一点。
-
// CORRECTED
import { Inject } from '@angular/core';
@@ -1544,7 +1532,6 @@ export function _window() { return window; }
export class MyComponent {
constructor (@Inject(WINDOW) private win: Window) { ... }
}
-
The `Window` type in the constructor is no longer a problem for the compiler because it
@@ -1557,7 +1544,6 @@ Angular does something similar with the `DOCUMENT` token so you can inject the b
Angular 也用 `DOCUMENT` 令牌做了类似的事情,所以你也可以注入浏览器的 `document` 对象(或它的一个抽象层,取决于该应用运行在哪个平台)。
-
import { Inject } from '@angular/core';
import { DOCUMENT } from '@angular/platform-browser';
@@ -1565,7 +1551,6 @@ import { DOCUMENT } from '@angular/platform-browser';
export class MyComponent {
constructor (@Inject(DOCUMENT) private doc: Document) { ... }
}
-
@@ -1613,7 +1598,6 @@ The compiler can understand simple enum values but not complex values such as th
编译器可以理解简单的枚举值,但不能理解复杂的,比如从那些计算属性中派生出来的。
-
// ERROR
enum Colors {
Red = 1,
@@ -1628,7 +1612,6 @@ enum Colors {
{ provide: StrongColor, useValue: Colors.Blue } // bad
]
...
-
Avoid referring to enums with complicated initializers or computed properties.
@@ -1915,28 +1898,28 @@ Chuck: After reviewing your PR comment I'm still at a loss. See [comment there](
* What the AOT compiler does and why it is important.
- 什么是 AOT 编译器,以及它为什么如此重要。
+ 什么是 AOT 编译器,以及它为什么如此重要。
* Why metadata must be written in a subset of JavaScript.
- 为何元数据必须使用 JavaScript 的一个子集来书写。
+ 为何元数据必须使用 JavaScript 的一个子集来书写。
* What that subset is.
- 这个子集是什么。
+ 这个子集是什么。
* Other restrictions on metadata definition.
- 定义元数据时的其它限制。
+ 定义元数据时的其它限制。
* Macro-functions and macro-static methods.
- 宏函数和静态宏函数。
+ 宏函数和静态宏函数。
* Compiler errors related to metadata.
- 与元数据有关的编译器错误。
+ 与元数据有关的编译器错误。
* Validation of binding expressions
- 验证绑定表达式。
+ 验证绑定表达式。
diff --git a/aio/content/guide/api-page-class.md b/aio/content/guide/api-page-class.md
index 58e8e16edd..6261f05257 100644
--- a/aio/content/guide/api-page-class.md
+++ b/aio/content/guide/api-page-class.md
@@ -4,9 +4,7 @@
Intro description text about what the example is and how it can be used.
-
constructor(element: any, keyframes:{[key:string]:string| number;
diff --git a/aio/content/guide/architecture-modules.md b/aio/content/guide/architecture-modules.md
index e99b16a06c..cff91123a6 100644
--- a/aio/content/guide/architecture-modules.md
+++ b/aio/content/guide/architecture-modules.md
@@ -10,6 +10,8 @@ While a small application might have only one NgModule, most apps have many more
## NgModule metadata
+## `@NgModule` 元数据
+
An NgModule is defined as a class decorated with `@NgModule`. The `@NgModule` decorator is a function that takes a single metadata object, whose properties describe the module. The most important properties are as follows.
* `declarations`—The [components](guide/architecture-components), _directives_, and _pipes_ that belong to this NgModule.
diff --git a/aio/content/guide/architecture.md b/aio/content/guide/architecture.md
index e843637e9d..7b2a1c6e61 100644
--- a/aio/content/guide/architecture.md
+++ b/aio/content/guide/architecture.md
@@ -1,4 +1,4 @@
-# Architecture Overview
+# Architecture overview
# 架构概览
@@ -122,6 +122,8 @@ To define navigation rules, you associate *navigation paths* with your component
## What's next
+## 接下来呢?
+
You've learned the basics about the main building blocks of an Angular application. The following diagram shows how these basic pieces are related.
diff --git a/aio/content/guide/attribute-directives.md b/aio/content/guide/attribute-directives.md
index 3e4dc9a283..071c52b146 100644
--- a/aio/content/guide/attribute-directives.md
+++ b/aio/content/guide/attribute-directives.md
@@ -83,9 +83,7 @@ Create the directive class file in a terminal window with this CLI command.
在命令行窗口下用 CLI 命令创建指令类文件。
-
ng generate directive highlight
-
The CLI creates `src/app/highlight.directive.ts`, a corresponding test file (`.../spec.ts`, and _declares_ the directive class in the root `AppModule`.
@@ -197,9 +195,7 @@ Now run the application to see the `HighlightDirective` in action.
运行这个应用以查看 `HighlightDirective` 的实际效果。
-
ng serve
-
To summarize, Angular found the `appHighlight` attribute on the **host** `
` element.
@@ -531,14 +527,12 @@ The final source code follows:
最终的源码如下:
-
-
You can also experience and download the .
@@ -624,12 +618,12 @@ Now apply that reasoning to the following example:
The template and its component trust each other.
The `color` property doesn't require the `@Input` decorator.
- `color` 属性位于右侧的绑定表达式中,它属于模板所在的组件。
+ `color` 属性位于右侧的绑定表达式中,它属于模板所在的组件。
该模板和组件相互信任。因此 `color` 不需要 `@Input` 装饰器。
* The `appHighlight` property on the left refers to an _aliased_ property of the `HighlightDirective`,
not a property of the template's component. There are trust issues.
Therefore, the directive property must carry the `@Input` decorator.
- `appHighlight` 属性位于左侧,它引用了 `HighlightDirective` 中一个*带别名的*属性,它不是模板所属组件的一部分,因此存在信任问题。
+ `appHighlight` 属性位于左侧,它引用了 `HighlightDirective` 中一个*带别名的*属性,它不是模板所属组件的一部分,因此存在信任问题。
所以,该属性必须带 `@Input` 装饰器。
diff --git a/aio/content/guide/bootstrapping.md b/aio/content/guide/bootstrapping.md
index 4e19a13227..662ebcbb63 100644
--- a/aio/content/guide/bootstrapping.md
+++ b/aio/content/guide/bootstrapping.md
@@ -12,7 +12,7 @@ A basic understanding of the following:
* [JavaScript Modules vs. NgModules](guide/ngmodule-vs-jsmodule).
- [JavaScript 模块与 NgModules](guide/ngmodule-vs-jsmodule).
+ [JavaScript 模块与 NgModules](guide/ngmodule-vs-jsmodule)。
@@ -69,15 +69,15 @@ The `@NgModule` decorator identifies `AppModule` as an `NgModule` class.
* **_declarations_**—this application's lone component.
- **_declarations_** —— 该应用所拥有的组件。
+ **_declarations_** —— 该应用所拥有的组件。
* **_imports_**—import `BrowserModule` to have browser specific services such as DOM rendering, sanitization, and location.
- **_imports_** —— 导入 `BrowserModule` 以获取浏览器特有的服务,比如 DOM 渲染、无害化处理和位置(location)。
+ **_imports_** —— 导入 `BrowserModule` 以获取浏览器特有的服务,比如 DOM 渲染、无害化处理和位置(location)。
* **_providers_**—the service providers.
- **_providers_** —— 各种服务提供商。
+ **_providers_** —— 各种服务提供商。
* **_bootstrap_**—the _root_ component that Angular creates and inserts
into the `index.html` host web page.
@@ -176,7 +176,6 @@ The following example, named `ItemDirective` is the default directive structure
下面的例子中,`item.directive.ts` 中的 `ItemDirective` 是 CLI 自动生成的默认指令结构。
-
The key point here is that you have to export it so you can import it elsewhere. Next, import it
@@ -185,7 +184,6 @@ into the NgModule, in this example `app.module.ts`, with a JavaScript import sta
重点在于你要先在这里导出它才能在别处导入它。接下来,使用 JavaScript 的 `import` 语句把它导入到 NgModule 中(这里是 `app.module.ts`)。
-
And in the same file, add it to the `@NgModule` `declarations` array:
@@ -193,7 +191,6 @@ And in the same file, add it to the `@NgModule` `declarations` array:
同样在这个文件中,把它添加到 `@NgModule` 的 `declarations` 数组中:
-
Now you could use your `ItemDirective` in a component. This example uses `AppModule`, but you'd do it the same way for a feature module. For more about directives, see [Attribute Directives](guide/attribute-directives) and [Structural Directives](guide/structural-directives). You'd also use the same technique for [pipes](guide/pipes) and components.
diff --git a/aio/content/guide/browser-support.md b/aio/content/guide/browser-support.md
index 553264a4f0..094b080ef5 100644
--- a/aio/content/guide/browser-support.md
+++ b/aio/content/guide/browser-support.md
@@ -81,7 +81,6 @@ Angular 支持大多数常用浏览器,包括下列版本:
-
@@ -97,9 +96,7 @@ Angular 支持大多数常用浏览器,包括下列版本:
-
-
@@ -115,7 +112,6 @@ Angular 支持大多数常用浏览器,包括下列版本:
-
@@ -133,7 +129,6 @@ Angular 支持大多数常用浏览器,包括下列版本:
-
@@ -151,7 +146,6 @@ Angular 支持大多数常用浏览器,包括下列版本:
-
@@ -239,7 +233,6 @@ For example, [if you need the web animations polyfill](http://caniuse.com/#feat=
# it isn't a strict requirement of Angular anymore (more below)
npm install --save web-animations-js
-
Then open the `polyfills.ts` file and un-comment the corresponding `import` statement as in the following example:
@@ -247,7 +240,6 @@ Then open the `polyfills.ts` file and un-comment the corresponding `import` stat
然后打开 `polyfills.ts` 文件,并反注释对应的 `import` 语句,就像这样:
-
/**
* Required to support Web Animations `@angular/platform-browser/animations`.
@@ -255,7 +247,6 @@ Then open the `polyfills.ts` file and un-comment the corresponding `import` stat
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
**/
import 'web-animations-js'; // Run `npm install --save web-animations-js`.
-
If you can't find the polyfill you want in `polyfills.ts`,
@@ -799,7 +790,6 @@ If you are not using the CLI, you should add your polyfill scripts directly to t
如果你不使用 CLI,就要直接把腻子脚本添加到宿主页(`index.html`)中,就像这样:
-
<!-- pre-zone polyfills -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/web-animations-js/web-animations.min.js"></script>
@@ -828,5 +818,4 @@ If you are not using the CLI, you should add your polyfill scripts directly to t
<script src="node_modules/zone.js/dist/zone.js"></script>
<!-- application polyfills -->
-
diff --git a/aio/content/guide/change-log.md b/aio/content/guide/change-log.md
index dc82bc2dad..1561b81d12 100644
--- a/aio/content/guide/change-log.md
+++ b/aio/content/guide/change-log.md
@@ -431,5 +431,4 @@ modules with SystemJS as the samples currently do.
The [Lifecycle Hooks](guide/lifecycle-hooks) guide is shorter, simpler, and
draws more attention to the order in which Angular calls the hooks.
-
[生命周期钩子](guide/lifecycle-hooks)章现在更加简短,并且对强调了 Angular 是以什么顺序来调用钩子方法的。
diff --git a/aio/content/guide/cheatsheet.md b/aio/content/guide/cheatsheet.md
index 237026f6a1..ddc00029ad 100644
--- a/aio/content/guide/cheatsheet.md
+++ b/aio/content/guide/cheatsheet.md
@@ -18,13 +18,11 @@
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
-
-
@@ -42,7 +40,6 @@
-
@@ -57,13 +54,11 @@
import { NgModule } from '@angular/core';
-
-
@@ -162,7 +157,6 @@ is available to declarations of this module.
-
@@ -181,7 +175,6 @@ is available to declarations of this module.
-
@@ -410,7 +403,6 @@ is available to declarations of this module.
-
@@ -427,13 +419,11 @@ is available to declarations of this module.
import { CommonModule } from '@angular/common';
-
-
@@ -499,7 +489,6 @@ is available to declarations of this module.
-
@@ -517,7 +506,6 @@ is available to declarations of this module.
-
@@ -534,13 +522,11 @@ is available to declarations of this module.
import { FormsModule } from '@angular/forms';
-
-
@@ -558,7 +544,6 @@ is available to declarations of this module.
-
@@ -575,13 +560,11 @@ is available to declarations of this module.
import { Directive, ... } from '@angular/core';
-
-
@@ -641,16 +624,13 @@ is available to declarations of this module.
Declares that a class has dependencies that should be injected into the constructor when the dependency injector is creating an instance of this class.
-
-
声明某个类具有一些依赖。当依赖注入器要创建这个类的实例时,应该把这些依赖注入到它的构造函数中。
-
@@ -667,13 +647,11 @@ is available to declarations of this module.
@Directive({ property1: value1, ... })
-
-
@@ -712,7 +690,6 @@ is available to declarations of this module.
-
@@ -728,7 +705,8 @@ is available to declarations of this module.
-
@Component extends @Directive,
+
+@Component extends @Directive,
so the @Directive configuration applies to components as well
@Component 继承自 @Directive,
@@ -737,7 +715,6 @@ so the @Directive configuration applies to components as well
-
@@ -803,7 +780,6 @@ so the @Directive configuration applies to components as well
-
@@ -820,13 +796,11 @@ so the @Directive configuration applies to components as well
import { Input, ... } from '@angular/core';
-
-
@@ -957,7 +931,6 @@ so the @Directive configuration applies to components as well
-
@@ -974,15 +947,13 @@ so the @Directive configuration applies to components as well
(implemented as class methods)
-
-
由类的方法实现。
+
由类的方法实现。
-
@@ -1128,7 +1099,6 @@ so the @Directive configuration applies to components as well
-
@@ -1147,7 +1117,6 @@ so the @Directive configuration applies to components as well
-
@@ -1197,7 +1166,6 @@ so the @Directive configuration applies to components as well
-
@@ -1214,13 +1182,11 @@ so the @Directive configuration applies to components as well
import { Routes, RouterModule, ... } from '@angular/router';
-
-
@@ -1366,7 +1332,6 @@ so the @Directive configuration applies to components as well
-
diff --git a/aio/content/guide/comparing-observables.md b/aio/content/guide/comparing-observables.md
index 8759e56f9e..d0bffb73ae 100644
--- a/aio/content/guide/comparing-observables.md
+++ b/aio/content/guide/comparing-observables.md
@@ -21,52 +21,48 @@ Observables are often compared to promises. Here are some key differences:
* Observables are declarative; computation does not start until subscription. Promises execute immediately on creation. This makes observables useful for defining recipes that can be run whenever you need the result.
- 可观察对象是声明式的,在被订阅之前,它不会开始执行。承诺是在创建时就立即执行的。这让可观察对象可用于定义那些应该按需执行的菜谱。
+ 可观察对象是声明式的,在被订阅之前,它不会开始执行。承诺是在创建时就立即执行的。这让可观察对象可用于定义那些应该按需执行的菜谱。
* Observables provide many values. Promises provide one. This makes observables useful for getting multiple values over time.
- 可观察对象能提供多个值。承诺只提供一个。这让可观察对象可用于随着时间的推移获取多个值。
+ 可观察对象能提供多个值。承诺只提供一个。这让可观察对象可用于随着时间的推移获取多个值。
* Observables differentiate between chaining and subscription. Promises only have `.then()` clauses. This makes observables useful for creating complex transformation recipes to be used by other part of the system, without causing the work to be executed.
- 可观察对象会区分串联处理和订阅语句。承诺只有 `.then()` 语句。这让可观察对象可用于创建供系统的其它部分使用而不希望立即执行的复杂菜谱。
+ 可观察对象会区分串联处理和订阅语句。承诺只有 `.then()` 语句。这让可观察对象可用于创建供系统的其它部分使用而不希望立即执行的复杂菜谱。
* Observables `subscribe()` is responsible for handling errors. Promises push errors to the child promises. This makes observables useful for centralized and predictable error handling.
- 可观察对象的 `subscribe()` 会负责处理错误。承诺会把错误推送给它的子承诺。这让可观察对象可用于进行集中式、可预测的错误处理。
+ 可观察对象的 `subscribe()` 会负责处理错误。承诺会把错误推送给它的子承诺。这让可观察对象可用于进行集中式、可预测的错误处理。
### Creation and subscription
### 创建与订阅
-* Observables are not executed until a consumer subscribes. The `subscribe()` executes the defined behavior once, and it can be called again. Each subscription has its own computation. Resubscription causes recomputation of values.
+* Observables are not executed until a consumer subcribes. The `subscribe()` executes the defined behavior once, and it can be called again. Each subscription has its own computation. Resubscription causes recomputation of values.
- 在有消费者订阅之前,可观察对象不会执行。`subscribe()` 会执行一次定义好的行为,并且可以再次调用它。每次订阅都是单独计算的。重新订阅会导致重新计算这些值。
+ 在有消费者订阅之前,可观察对象不会执行。`subscribe()` 会执行一次定义好的行为,并且可以再次调用它。每次订阅都是单独计算的。重新订阅会导致重新计算这些值。
-
// declare a publishing operation
new Observable((observer) => { subscriber_fn });
// initiate execution
observable.subscribe(() => {
// observer handles notifications
});
-
* Promises execute immediately, and just once. The computation of the result is initiated when the promise is created. There is no way to restart work. All `then` clauses (subscriptions) share the same computation.
- 承诺会立即执行,并且只执行一次。当承诺创建时,会立即计算出结果。没有办法重新做一次。所有的 `then` 语句(订阅)都会共享同一次计算。
+ 承诺会立即执行,并且只执行一次。当承诺创建时,会立即计算出结果。没有办法重新做一次。所有的 `then` 语句(订阅)都会共享同一次计算。
-
// initiate execution
new Promise((resolve, reject) => { executer_fn });
// handle return value
promise.then((value) => {
// handle result here
});
-
### Chaining
@@ -75,13 +71,13 @@ promise.then((value) => {
* Observables differentiate between transformation function such as a map and subscription. Only subscription activates the subscriber function to start computing the values.
- 可观察对象会区分各种转换函数,比如映射和订阅。只有订阅才会激活订阅者函数,以开始计算那些值。
+ 可观察对象会区分各种转换函数,比如映射和订阅。只有订阅才会激活订阅者函数,以开始计算那些值。
observable.map((v) => 2*v);
* Promises do not differentiate between the last `.then` clauses (equivalent to subscription) and intermediate `.then` clauses (equivalent to map).
- 承诺并不区分最后的 `.then()` 语句(等价于订阅)和中间的 `.then()` 语句(等价于映射)。
+ 承诺并不区分最后的 `.then()` 语句(等价于订阅)和中间的 `.then()` 语句(等价于映射)。
promise.then((v) => 2*v);
@@ -91,18 +87,16 @@ promise.then((value) => {
* Observable subscriptions are cancellable. Unsubscribing removes the listener from receiving further values, and notifies the subscriber function to cancel work.
- 可观察对象的订阅是可取消的。取消订阅会移除监听器,使其不再接受将来的值,并通知订阅者函数取消正在进行的工作。
+ 可观察对象的订阅是可取消的。取消订阅会移除监听器,使其不再接受将来的值,并通知订阅者函数取消正在进行的工作。
-
const sub = obs.subscribe(...);
sub.unsubscribe();
-
* Promises are not cancellable.
- 承诺是不可取消的。
+ 承诺是不可取消的。
### Error handling
@@ -110,26 +104,22 @@ sub.unsubscribe();
* Observable execution errors are delivered to the subscriber's error handler, and the subscriber automatically unsubscribes from the observable.
- 可观察对象的错误处理是交给订阅者的错误处理器的,并且该订阅者会自动取消对这个可观察对象的订阅。
+ 可观察对象的错误处理是交给订阅者的错误处理器的,并且该订阅者会自动取消对这个可观察对象的订阅。
-
obs.subscribe(() => {
throw Error('my error');
});
-
* Promises push errors to the child promises.
- 承诺会把错误推给其子承诺。
+ 承诺会把错误推给其子承诺。
-
promise.then(() => {
throw Error('my error');
});
-
### Cheat sheet
@@ -141,7 +131,6 @@ The following code snippets illustrate how the same kind of operation is defined
下列代码片段揭示了同样的操作要如何分别使用可观察对象和承诺进行实现。
-
@@ -169,7 +158,6 @@ The following code snippets illustrate how the same kind of operation is defined
-
@@ -197,7 +185,6 @@ The following code snippets illustrate how the same kind of operation is defined
-
@@ -221,7 +208,6 @@ The following code snippets illustrate how the same kind of operation is defined
-
@@ -249,7 +235,6 @@ The following code snippets illustrate how the same kind of operation is defined
-
@@ -275,7 +260,6 @@ The following code snippets illustrate how the same kind of operation is defined
-
## Observables compared to events API
@@ -295,9 +279,12 @@ Here are some code samples that illustrate how the same kind of operation is def
下列代码片段揭示了同样的操作要如何分别使用可观察对象和事件 API 进行实现。
-
+
+
+
+
Observable
@@ -315,7 +302,6 @@ Here are some code samples that illustrate how the same kind of operation is def
## Observables compared to arrays
@@ -431,9 +414,12 @@ An observable produces values over time. An array is created as a static set of
在下列例子中,➞ 符号表示异步传递值。
-
+
+
+
+
Observable
@@ -451,7 +437,6 @@ An observable produces values over time. An array is created as a static set of
-
@@ -465,6 +450,7 @@ An observable produces values over time. An array is created as a static set of
obs: ➞1➞2➞3➞5➞7
+
obsB: ➞'a'➞'b'➞'c'
@@ -472,12 +458,12 @@ An observable produces values over time. An array is created as a static set of
arr: [1, 2, 3, 5, 7]
+
arrB: ['a', 'b', 'c']
-
@@ -489,6 +475,7 @@ An observable produces values over time. An array is created as a static set of
obs.concat(obsB)
+
➞1➞2➞3➞5➞7➞'a'➞'b'➞'c'
@@ -496,12 +483,12 @@ An observable produces values over time. An array is created as a static set of
arr.concat(arrB)
+
[1,2,3,5,7,'a','b','c']
-
@@ -513,6 +500,7 @@ An observable produces values over time. An array is created as a static set of
obs.filter((v) => v>3)
+
➞5➞7
@@ -520,12 +508,12 @@ An observable produces values over time. An array is created as a static set of
arr.filter((v) => v>3)
+
[5, 7]
-
@@ -537,6 +525,7 @@ An observable produces values over time. An array is created as a static set of
obs.find((v) => v>3)
+
➞5
@@ -544,12 +533,12 @@ An observable produces values over time. An array is created as a static set of
arr.find((v) => v>10)
+
5
-
@@ -561,6 +550,7 @@ An observable produces values over time. An array is created as a static set of
obs.findIndex((v) => v>3)
+
➞3
@@ -568,12 +558,12 @@ An observable produces values over time. An array is created as a static set of
arr.findIndex((v) => v>3)
+
3
-
@@ -609,7 +599,6 @@ An observable produces values over time. An array is created as a static set of
-
@@ -621,6 +610,7 @@ An observable produces values over time. An array is created as a static set of
obs.map((v) => -v)
+
➞-1➞-2➞-3➞-5➞-7
@@ -628,12 +618,12 @@ An observable produces values over time. An array is created as a static set of
arr.map((v) => -v)
+
[-1, -2, -3, -5, -7]
-
@@ -645,6 +635,7 @@ An observable produces values over time. An array is created as a static set of
obs.scan((s,v)=> s+v, 0)
+
➞1➞3➞6➞11➞18
@@ -652,10 +643,10 @@ An observable produces values over time. An array is created as a static set of
arr.reduce((s,v) => s+v, 0)
+
18
-
diff --git a/aio/content/guide/component-interaction.md b/aio/content/guide/component-interaction.md
index b6c43cfa68..343d078b2c 100644
--- a/aio/content/guide/component-interaction.md
+++ b/aio/content/guide/component-interaction.md
@@ -525,5 +525,4 @@ and verify that the history meets expectations:
[Back to top](guide/component-interaction#top)
-
[回到顶部](guide/component-interaction#top)
diff --git a/aio/content/guide/component-styles.md b/aio/content/guide/component-styles.md
index 113e6fb696..9c28c78889 100644
--- a/aio/content/guide/component-styles.md
+++ b/aio/content/guide/component-styles.md
@@ -20,7 +20,7 @@ This page describes how to load and apply these component styles.
You can run the in Stackblitz and download the code from there.
-你可以运行来在 Stackblitz 中试用并下载本页的代码。
+你可以运行,在 Stackblitz 中试用并下载本页的代码。
## Using component styles
@@ -42,7 +42,6 @@ Usually you give it one string, as in the following example:
通常你只给它一个字符串就行了,如同下例:
-
## Style scope
@@ -116,7 +115,6 @@ targeting elements *inside* the component's template).
使用 `:host` 伪类选择器,用来选择组件*宿主*元素中的元素(相对于组件模板*内部*的元素)。
-
The `:host` selector is the only way to target the host element. You can't reach
@@ -136,7 +134,6 @@ The next example targets the host element again, but only when it also has the `
下一个例子再次把宿主元素作为目标,但是只有当它同时带有 `active` CSS 类的时候才会生效。
-
### :host-context
@@ -163,7 +160,6 @@ if some ancestor element has the CSS class `theme-light`.
在下面的例子中,只有当某个祖先元素有 CSS 类 `theme-light` 时,才会把 `background-color` 样式应用到组件*内部*的所有 `
` 元素中。
-
### (deprecated) `/deep/`, `>>>`, and `::ng-deep`
@@ -257,7 +253,6 @@ Each string in the array defines some CSS for this component.
这个数组中的每一个字符串(通常也只有一个)定义一份 CSS。
-
@@ -275,9 +270,7 @@ The CLI defines an empty `styles` array when you create the component with the `
当使用 `--inline-styles` 标识创建组件时,CLI 就会定义一个空的 `styles` 数组
-
ng generate component hero-app --inline-style
-
### Style files in component metadata
@@ -290,10 +283,8 @@ to a component's `@Component` decorator:
你可以通过把外部 CSS 文件添加到 `@Component` 的 `styleUrls` 属性中来加载外部样式。
-
-
@@ -319,9 +310,7 @@ The CLI creates an empty styles file for you by default and references that file
CLI 会默认为你创建一个空白的样式表文件,并且在所生成组件的 `styleUrls` 中引用该文件。
-
ng generate component hero-app
-
### Template inline styles
@@ -334,7 +323,6 @@ inside `
-
@@ -1266,7 +1246,6 @@ Use HTML tables to present tabular data.
-
@@ -1290,7 +1269,6 @@ Use HTML tables to present tabular data.
-
@@ -1316,7 +1294,6 @@ Use HTML tables to present tabular data.
-
@@ -1340,7 +1317,6 @@ Use HTML tables to present tabular data.
-
Here is the markup for this table.
@@ -1352,7 +1328,6 @@ Here is the markup for this table.
-
@@ -1374,7 +1349,6 @@ Here is the markup for this table.
-
@@ -1398,7 +1372,6 @@ Here is the markup for this table.
-
@@ -1424,7 +1397,6 @@ Here is the markup for this table.
-
@@ -1448,7 +1420,6 @@ Here is the markup for this table.
-
```
diff --git a/aio/content/guide/dynamic-form.md b/aio/content/guide/dynamic-form.md
index 1ffe1469a1..87e86b8e26 100644
--- a/aio/content/guide/dynamic-form.md
+++ b/aio/content/guide/dynamic-form.md
@@ -266,5 +266,4 @@ The final form looks like this:
[Back to top](guide/dynamic-form#top)
-
[回到顶部](guide/dynamic-form#top)
diff --git a/aio/content/guide/entry-components.md b/aio/content/guide/entry-components.md
index d4663c846a..85817c3a7d 100644
--- a/aio/content/guide/entry-components.md
+++ b/aio/content/guide/entry-components.md
@@ -12,7 +12,7 @@ A basic understanding of the following concepts:
* [Bootstrapping](guide/bootstrapping).
- [引导](guide/bootstrapping)。
+ [引导启动](guide/bootstrapping)。
@@ -35,11 +35,11 @@ There are two main kinds of entry components:
* The bootstrapped root component.
- 引导用的根组件。
+ 引导用的根组件。
* A component you specify in a route definition.
- 在路由定义中指定的组件。
+ 在路由定义中指定的组件。
## A bootstrapped entry component
@@ -172,16 +172,16 @@ You may also be interested in the following:
* [Types of NgModules](guide/module-types)
- [Angular 模块的分类](guide/module-types)
+ [NgModule 的分类](guide/module-types).
* [Lazy Loading Modules with the Angular Router](guide/lazy-loading-ngmodules).
- [使用 Angular 路由器实现惰性加载模块](guide/lazy-loading-ngmodules).
+ [使用 Angular 路由器惰性加载模块](guide/lazy-loading-ngmodules)。
* [Providers](guide/providers).
- [服务提供商](guide/providers).
+ [服务提供商](guide/providers)。
* [NgModules FAQ](guide/ngmodule-faq).
- [NgModule 常见问题](guide/ngmodule-faq).
+ [NgModule 常见问题](guide/ngmodule-faq).
diff --git a/aio/content/guide/feature-modules.md b/aio/content/guide/feature-modules.md
index a6c7e7ab21..1ed01ff964 100644
--- a/aio/content/guide/feature-modules.md
+++ b/aio/content/guide/feature-modules.md
@@ -16,15 +16,15 @@ A basic understanding of the following:
* [Bootstrapping](guide/bootstrapping).
- [引导](guide/bootstrapping)。
+ [引导启动](guide/bootstrapping)。
* [JavaScript Modules vs. NgModules](guide/ngmodule-vs-jsmodule).
- [JavaScript 模块与 NgModules](guide/ngmodule-vs-jsmodule)。
+ [JavaScript 模块与 NgModules](guide/ngmodule-vs-jsmodule)。
* [Frequently Used Modules](guide/frequent-ngmodules).
- [常用模块](guide/frequent-ngmodules).
+ [常用模块](guide/frequent-ngmodules)。
For the final sample app with a feature module that this page describes,
see the .
@@ -118,7 +118,6 @@ This generates a folder for the new component within the customer-dashboard fold
这会在 `customer-dashboard` 中为新组件生成一个目录,并使用 `CustomerDashboardComponent` 的信息修改这个特性模块:
-
The `CustomerDashboardComponent` is now in the JavaScript import list at the top and added to the `declarations` array, which lets Angular know to associate this new component with this feature module.
@@ -134,7 +133,6 @@ To incorporate the feature module into your app, you have to let the root module
要想把这个特性模块包含进应用中,你还得让根模块 `app.module.ts` 知道它。注意,在 `customer-dashboard.module.ts` 的底部导出了 `CustomerDashboardModule`。这样就把它暴露出来,以便其它模块可以拿到它。要想把它导入到 `AppModule` 中,就把它加入 `app.module.ts` 的导入表中,并将其加入 `imports` 数组:
-
Now the `AppModule` knows about the feature module. If you were to add any service providers to the feature module, `AppModule` would know about those too, as would any other feature modules. However, NgModules don’t expose their components.
@@ -150,7 +148,6 @@ When the CLI generated the `CustomerDashboardComponent` for the feature module,
当 CLI 为这个特性模块生成 `CustomerDashboardComponent` 时,还包含一个模板 `customer-dashboard.component.html`,它带有如下页面脚本:
-
To see this HTML in the `AppComponent`, you first have to export the `CustomerDashboardComponent` in the `CustomerDashboardModule`. In `customer-dashboard.module.ts`, just beneath the `declarations` array, add an `exports` array containing `CustomerDashboardModule`:
@@ -159,7 +156,6 @@ To see this HTML in the `AppComponent`, you first have to export the `CustomerDa
在 `customer-dashboard.module.ts` 中,`declarations` 数组的紧下方,加入一个包含 `CustomerDashboardModule` 的 `exports` 数组:
-
Next, in the `AppComponent`, `app.component.html`, add the tag ``:
@@ -167,7 +163,6 @@ Next, in the `AppComponent`, `app.component.html`, add the tag ``:
-
Now, in addition to the title that renders by default, the `CustomerDashboardComponent` template renders too:
@@ -190,12 +185,12 @@ You may also be interested in the following:
* [Lazy Loading Modules with the Angular Router](guide/lazy-loading-ngmodules).
- [使用 Angular 路由器实现惰性加载模块](guide/lazy-loading-ngmodules).
+ [使用 Angular 路由器惰性加载模块](guide/lazy-loading-ngmodules)。
* [Providers](guide/providers).
- [服务提供商](guide/providers).
+ [服务提供商](guide/providers)。
* [Types of Feature Modules](guide/module-types).
- [Angular 模块的分类](guide/module-types)
+ [特性模块的分类](guide/module-types)。
diff --git a/aio/content/guide/form-validation.md b/aio/content/guide/form-validation.md
index 3a376aa849..f30714ba88 100644
--- a/aio/content/guide/form-validation.md
+++ b/aio/content/guide/form-validation.md
@@ -140,7 +140,6 @@ built-in validators—this time, in function form. See below:
{@a reactive-component-class}
-
Note that:
@@ -169,7 +168,6 @@ If you look at the template for the name input again, it is fairly similar to th
如果你到模板中找到 name 输入框,就会发现它和模板驱动的例子很相似。
-
Key takeaways:
@@ -201,7 +199,6 @@ this guide. Here's what the definition of that function looks like:
考虑前面的[例子](guide/form-validation#reactive-component-class)中的 `forbiddenNameValidator` 函数。该函数的定义看起来是这样的:
-
The function is actually a factory that takes a regular expression to detect a _specific_ forbidden name and returns a validator function.
@@ -241,7 +238,6 @@ to the `FormControl`.
在响应式表单组件中,添加自定义验证器相当简单。你所要做的一切就是直接把这个函数传给 `FormControl` 。
-
### Adding to template-driven forms
@@ -263,7 +259,6 @@ with the `NG_VALIDATORS` provider, a provider with an extensible collection of v
Angular 在验证流程中的识别出指令的作用,是因为指令把自己注册到了 `NG_VALIDATORS` 提供商中,该提供商拥有一组可扩展的验证器。
-
The directive class then implements the `Validator` interface, so that it can easily integrate
@@ -273,7 +268,6 @@ comes together:
然后该指令类实现了 `Validator` 接口,以便它能简单的与 Angular 表单集成在一起。这个指令的其余部分有助于你理解它们是如何协作的:
-
Once the `ForbiddenValidatorDirective` is ready, you can simply add its selector, `appForbiddenName`, to any input element to activate it. For example:
@@ -330,5 +324,4 @@ set the color of each form control's border.
**You can run the to see the complete reactive and template-driven example code.**
-
**你可以运行来查看完整的响应式和模板驱动表单的代码。**
diff --git a/aio/content/guide/forms.md b/aio/content/guide/forms.md
index 1964fdaa12..8fcb03fdfb 100644
--- a/aio/content/guide/forms.md
+++ b/aio/content/guide/forms.md
@@ -49,7 +49,7 @@ This page shows you how to build a simple form from scratch. Along the way you'l
You can run the in Stackblitz and download the code from there.
-运行来试用本页的代码。
+你可以运行,在 Stackblitz 中试用并下载本页的代码。
{@a template-driven}
diff --git a/aio/content/guide/frequent-ngmodules.md b/aio/content/guide/frequent-ngmodules.md
index c5f724a42c..2b58c60a23 100644
--- a/aio/content/guide/frequent-ngmodules.md
+++ b/aio/content/guide/frequent-ngmodules.md
@@ -8,7 +8,7 @@
A basic understanding of [Bootstrapping](guide/bootstrapping).
-对[引导](guide/bootstrapping)有基本的理解。
+对[引导](guide/bootstrapping)有基本的了解。
@@ -287,4 +287,4 @@ You may also be interested in the following:
* [JavaScript Modules vs. NgModules](guide/ngmodule-vs-jsmodule).
- [JavaScript 模块与 NgModules](guide/ngmodule-vs-jsmodule).
+ [JavaScript 模块与 NgModules](guide/ngmodule-vs-jsmodule)。
diff --git a/aio/content/guide/glossary.md b/aio/content/guide/glossary.md
index 871ab68572..ab4b2a1cfb 100644
--- a/aio/content/guide/glossary.md
+++ b/aio/content/guide/glossary.md
@@ -83,7 +83,6 @@ For example, imagine three ES2015 modules in a `heroes` folder:
例如,设想在 `heroes` 目录下有三个 ES2015 模块:
-
// heroes/hero.component.ts
export class HeroComponent {}
@@ -92,7 +91,6 @@ For example, imagine three ES2015 modules in a `heroes` folder:
// heroes/hero.service.ts
export class HeroService {}
-
Without a barrel, a consumer needs three import statements:
@@ -100,11 +98,9 @@ Without a barrel, a consumer needs three import statements:
如果没有封装桶,消费者需要三条导入语句:
-
import { HeroComponent } from '../heroes/hero.component.ts';
import { Hero } from '../heroes/hero.model.ts';
import { HeroService } from '../heroes/hero.service.ts';
-
You can add a barrel to the `heroes` folder (called `index`, by convention) that exports all of these items:
@@ -112,11 +108,9 @@ You can add a barrel to the `heroes` folder (called `index`, by convention) that
在 `heroes` 目录下添加一个封装桶(按约定叫做 `index`),它导出所有这三项:
-
export * from './hero.model.ts'; // re-export all of its exports
export * from './hero.service.ts'; // re-export all of its exports
export { HeroComponent } from './hero.component.ts'; // re-export the named thing
-
Now a consumer can import what it needs from the barrel.
@@ -124,9 +118,7 @@ Now a consumer can import what it needs from the barrel.
现在,消费者就就可以从这个封装桶中导入它需要的东西了。
-
import { Hero, HeroService } from '../heroes'; // index is implied
-
The Angular [scoped packages](guide/glossary#scoped-package) each have a barrel named `index`.
@@ -615,7 +607,6 @@ or displayed between element tags, as in this example.
在被赋值给元素属性或者显示在元素标签中之前,这些文本可能会先与周边的文本合并,参见下面的例子。
-
@@ -870,7 +861,6 @@ Angular 管道是一个函数,用于把输入值转换成输出值以供[视
下面这个例子中,用内置的 `currency` 管道把数字值显示为本地货币格式。
-
{{product.price | currency}}
@@ -1251,5 +1241,4 @@ Angular 会在一个 Zone 区域中运行应用程序,在这个区域中,它
Learn more about zones in this
[Brian Ford video](https://www.youtube.com/watch?v=3IqtmUscE_U).
-
更多信息,见 [Brian Ford 的视频](https://www.youtube.com/watch?v=3IqtmUscE_U)。
diff --git a/aio/content/guide/http.md b/aio/content/guide/http.md
index 6dc047d0ee..3faac973f9 100644
--- a/aio/content/guide/http.md
+++ b/aio/content/guide/http.md
@@ -45,7 +45,6 @@ Most apps do so in the root `AppModule`.
path="http/src/app/app.module.ts"
region="sketch"
title="app/app.module.ts (excerpt)" linenums="false">
-
Having imported `HttpClientModule` into the `AppModule`, you can inject the `HttpClient`
@@ -57,7 +56,6 @@ into an application class as shown in the following `ConfigService` example.
path="http/src/app/config/config.service.ts"
region="proto"
title="app/config/config.service.ts (excerpt)" linenums="false">
-
## Getting JSON data
@@ -74,7 +72,6 @@ that specifies resource URLs.
-
The `ConfigService` fetches this file with a `get()` method on `HttpClient`.
@@ -85,7 +82,6 @@ The `ConfigService` fetches this file with a `get()` method on `HttpClient`.
path="http/src/app/config/config.service.ts"
region="getConfig_1"
title="app/config/config.service.ts (getConfig v.1)" linenums="false">
-
A component, such as `ConfigComponent`, injects the `ConfigService` and calls
@@ -97,7 +93,6 @@ the `getConfig` service method.
path="http/src/app/config/config.component.ts"
region="v1"
title="app/config/config.component.ts (showConfig v.1)" linenums="false">
-
Because the service method returns an `Observable` of configuration data,
@@ -148,7 +143,6 @@ The subscribe callback above requires bracket notation to extract the data value
-
You can't write `data.heroesUrl` because TypeScript correctly complains that the `data` object from the service does not have a `heroesUrl` property.
@@ -170,7 +164,6 @@ First, define an interface with the correct shape:
-
Then, specify that interface as the `HttpClient.get()` call's type parameter in the service:
@@ -181,7 +174,6 @@ Then, specify that interface as the `HttpClient.get()` call's type parameter in
path="http/src/app/config/config.service.ts"
region="getConfig_2"
title="app/config/config.service.ts (getConfig v.2)" linenums="false">
-
The callback in the updated component method receives a typed data object, which is
@@ -193,7 +185,6 @@ easier and safer to consume:
path="http/src/app/config/config.component.ts"
region="v2"
title="app/config/config.component.ts (showConfig v.2)" linenums="false">
-
### Reading the full response
@@ -211,7 +202,6 @@ Tell `HttpClient` that you want the full response with the `observe` option:
-
Now `HttpClient.get()` returns an `Observable` of typed `HttpResponse` rather than just the JSON data.
@@ -227,7 +217,6 @@ The component's `showConfigResponse()` method displays the response headers as w
region="showConfigResponse"
title="app/config/config.component.ts (showConfigResponse)"
linenums="false">
-
As you can see, the response object has a `body` property of the correct type.
@@ -251,7 +240,6 @@ You _could_ handle in the component by adding a second callback to the `.subscri
region="v3"
title="app/config/config.component.ts (showConfig v.3 with error handling)"
linenums="false">
-
It's certainly a good idea to give the user some kind of feedback when data access fails.
@@ -296,7 +284,6 @@ You might first devise an error handler like this one:
path="http/src/app/config/config.service.ts"
region="handleError"
title="app/config/config.service.ts (handleError)" linenums="false">
-
Notice that this handler returns an RxJS [`ErrorObservable`](#rxjs) with a user-friendly error message.
@@ -315,7 +302,6 @@ and _pipe them through_ to the error handler.
path="http/src/app/config/config.service.ts"
region="getConfig_3"
title="app/config/config.service.ts (getConfig v.3 with error handler)" linenums="false">
-
### `retry()`
@@ -341,7 +327,6 @@ _Pipe_ it onto the `HttpClient` method result just before the error handler.
path="http/src/app/config/config.service.ts"
region="getConfig"
title="app/config/config.service.ts (getConfig with retry)" linenums="false">
-
{@a rxjs}
@@ -377,7 +362,6 @@ If you're following along with these code snippets, note that you must import th
path="http/src/app/config/config.service.ts"
region="rxjs-imports"
title="app/config/config.service.ts (RxJS imports)" linenums="false">
-
## Requesting non-JSON data
@@ -396,7 +380,6 @@ as an `Observable`.
path="http/src/app/downloader/downloader.service.ts"
region="getTextFile"
title="app/downloader/downloader.service.ts (getTextFile)" linenums="false">
-
`HttpClient.get()` returns a string rather than the default JSON because of the `responseType` option.
@@ -415,7 +398,6 @@ A `download()` method in the `DownloaderComponent` initiates the request by subs
path="http/src/app/downloader/downloader.component.ts"
region="download"
title="app/downloader/downloader.component.ts (download)" linenums="false">
-
## Sending data to the server
@@ -457,7 +439,6 @@ to every `HttpClient` save method.
path="http/src/app/heroes/heroes.service.ts"
region="http-options"
title="app/heroes/heroes.service.ts (httpOptions)" linenums="false">
-
### Making a POST request
@@ -474,7 +455,6 @@ In the following example, the `HeroService` posts when adding a hero to the data
path="http/src/app/heroes/heroes.service.ts"
region="addHero"
title="app/heroes/heroes.service.ts (addHero)" linenums="false">
-
The `HttpClient.post()` method is similar to `get()` in that it has a type parameter
@@ -510,7 +490,6 @@ the `Observable` returned by this service method.
path="http/src/app/heroes/heroes.component.ts"
region="add-hero-subscribe"
title="app/heroes/heroes.component.ts (addHero)" linenums="false">
-
When the server responds successfully with the newly added hero, the component adds
@@ -531,7 +510,6 @@ in the request URL.
path="http/src/app/heroes/heroes.service.ts"
region="deleteHero"
title="app/heroes/heroes.service.ts (deleteHero)" linenums="false">
-
The `HeroesComponent` initiates the actual DELETE operation by subscribing to
@@ -543,7 +521,6 @@ the `Observable` returned by this service method.
path="http/src/app/heroes/heroes.component.ts"
region="delete-hero-subscribe"
title="app/heroes/heroes.component.ts (deleteHero)" linenums="false">
-
@@ -570,7 +547,6 @@ Merely calling `HeroService.deleteHero()` **does not initiate the DELETE request
-
{@a always-subscribe}
@@ -643,7 +619,6 @@ The following `HeroService` example is just like the POST example.
path="http/src/app/heroes/heroes.service.ts"
region="updateHero"
title="app/heroes/heroes.service.ts (updateHero)" linenums="false">
-
For the reasons [explained above](#always-subscribe), the caller (`HeroesComponent.update()` in this case) must `subscribe()` to the observable returned from the `HttpClient.put()`
@@ -698,7 +673,6 @@ before making the next request.
-
#### URL Parameters
@@ -714,14 +688,13 @@ Here is a `searchHeroes` method that queries for heroes whose names contain the
-
If there is a search term, the code constructs an options object with an HTML URL encoded search parameter. If the term were "foo", the GET request URL would be `api/heroes/?name=foo`.
如果有搜索词,这段代码就会构造一个包含进行过 URL 编码的搜索词的选项对象。如果这个搜索词是“foo”,这个 GET 请求的 URL 就会是 `api/heroes/?name=foo`。
-The `HttpParams` are immutable so you'll have to use the `set()` method to update the options.
+The `HttpParms` are immutable so you'll have to use the `set()` method to update the options.
`HttpParams` 是不可变的,所以你也要使用 `set()` 方法来修改这些选项。
@@ -746,7 +719,6 @@ Here's a pertinent excerpt from the template:
path="http/src/app/package-search/package-search.component.html"
region="search"
title="app/package-search/package-search.component.html (search)">
-
The `(keyup)` event binding sends every keystroke to the component's `search()` method.
@@ -765,7 +737,6 @@ That's easy to implement with RxJS operators, as shown in this excerpt.
path="http/src/app/package-search/package-search.component.ts"
region="debounce"
title="app/package-search/package-search.component.ts (excerpt))">
-
The `searchText$` is the sequence of search-box values coming from the user.
@@ -875,15 +846,14 @@ To implement an interceptor, declare a class that implements the `intercept()` m
要实现拦截器,就要实现一个实现了 `HttpInterceptor` 接口中的 `intercept()` 方法的类。
-Here is a do-nothing _noop_ interceptor that simply passes the request through without touching it:
-
-这里是一个什么也不做的*空白*拦截器,它只会不做任何修改的传递这个请求。
-
+ Here is a do-nothing _noop_ interceptor that simply passes the request through without touching it:
+
+ 这里是一个什么也不做的*空白*拦截器,它只会不做任何修改的传递这个请求。
+
-
The `intercept` method transforms a request into an `Observable` that eventually returns the HTTP response.
@@ -963,7 +933,6 @@ write the `NoopInterceptor` provider like this:
-
Note the `multi: true` option.
@@ -990,7 +959,6 @@ Consider creating a "barrel" file that gathers all the interceptor providers int
path="http/src/app/http-interceptors/index.ts"
region="interceptor-providers"
title="app/http-interceptors/index.ts" linenums="false">
-
Then import and add it to the `AppModule` _providers array_ like this:
@@ -1001,7 +969,6 @@ Then import and add it to the `AppModule` _providers array_ like this:
path="http/src/app/app.module.ts"
region="interceptor-providers"
title="app/app.module.ts (interceptor providers)" linenums="false">
-
As you create new interceptors, add them to the `httpInterceptorProviders` array and
@@ -1100,7 +1067,6 @@ You can clone and modify the request in a single step as in this example.
path="http/src/app/http-interceptors/ensure-https-interceptor.ts"
region="excerpt"
title="app/http-interceptors/ensure-https-interceptor.ts (excerpt)" linenums="false">
-
The `clone()` method's hash argument allows you to mutate specific properties of the request while copying the others.
@@ -1131,7 +1097,6 @@ If you must mutate the request body, copy it first, change the copy,
path="http/src/app/http-interceptors/trim-name-interceptor.ts"
region="excerpt"
title="app/http-interceptors/trim-name-interceptor.ts (excerpt)" linenums="false">
-
##### Clearing the request body
@@ -1174,7 +1139,6 @@ adds an authorization header with that token to every outgoing request:
-
The practice of cloning a request to set new headers is so common that
@@ -1185,7 +1149,6 @@ there's a `setHeaders` shortcut for it:
-
An interceptor that alters headers can be used for a number of different operations, including:
@@ -1223,7 +1186,6 @@ with the injected `MessageService`.
path="http/src/app/http-interceptors/logging-interceptor.ts"
region="excerpt"
title="app/http-interceptors/logging-interceptor.ts)">
-
The RxJS `tap` operator captures whether the request succeed or failed.
@@ -1259,7 +1221,6 @@ The `CachingInterceptor` demonstrates this approach.
path="http/src/app/http-interceptors/caching-interceptor.ts"
region="v1"
title="app/http-interceptors/caching-interceptor.ts)" linenums="false">
-
The `isCachable()` function determines if the request is cachable.
@@ -1287,7 +1248,6 @@ If a cachable request is not in cache, the code calls `sendRequest`.
-
The `sendRequest` function creates a [request clone](#immutability) without headers
@@ -1343,7 +1303,6 @@ and emits again later with the updated search results.
-
The _cache-then-refresh_ option is triggered by the presence of a **custom `x-refresh` header**.
@@ -1407,7 +1366,6 @@ with the `reportProgress` option set true to enable tracking of progress events.
path="http/src/app/uploader/uploader.service.ts"
region="upload-request"
title="app/uploader/uploader.service.ts (upload request)">
-
@@ -1427,7 +1385,6 @@ returns an `Observable` of `HttpEvents`, the same events processed by intercepto
path="http/src/app/uploader/uploader.service.ts"
region="upload-body"
title="app/uploader/uploader.service.ts (upload body)" linenums="false">
-
The `getEventMessage` method interprets each type of `HttpEvent` in the event stream.
@@ -1438,7 +1395,6 @@ The `getEventMessage` method interprets each type of `HttpEvent` in the event st
path="http/src/app/uploader/uploader.service.ts"
region="getEventMessage"
title="app/uploader/uploader.service.ts (getEventMessage)" linenums="false">
-
@@ -1501,7 +1457,6 @@ use `HttpClientXsrfModule.withOptions()` to override the defaults.
path="http/src/app/app.module.ts"
region="xsrf"
linenums="false">
-
## Testing HTTP requests
@@ -1565,7 +1520,6 @@ along with the other symbols your tests require.
path="http/src/testing/http-client.spec.ts"
region="imports"
title="app/testing/http-client.spec.ts (imports)" linenums="false">
-
Then add the `HttpClientTestingModule` to the `TestBed` and continue with
@@ -1577,7 +1531,6 @@ the setup of the _service-under-test_.
path="http/src/testing/http-client.spec.ts"
region="setup"
title="app/testing/http-client.spec.ts(setup)" linenums="false">
-
Now requests made in the course of your tests will hit the testing backend instead of the normal backend.
@@ -1601,7 +1554,6 @@ Now you can write a test that expects a GET Request to occur and provides a mock
path="http/src/testing/http-client.spec.ts"
region="get-test"
title="app/testing/http-client.spec.ts(httpClient.get)" linenums="false">
-
The last step, verifying that no requests remain outstanding, is common enough for you to move it into an `afterEach()` step:
@@ -1612,7 +1564,6 @@ The last step, verifying that no requests remain outstanding, is common enough f
path="http/src/testing/http-client.spec.ts"
region="afterEach"
linenums="false">
-
#### Custom request expectations
@@ -1629,7 +1580,6 @@ For example, you could look for an outgoing request that has an authorization he
path="http/src/testing/http-client.spec.ts"
region="predicate"
linenums="false">
-
As with the previous `expectOne()`,
@@ -1652,7 +1602,6 @@ you are responsible for flushing and verifying them.
path="http/src/testing/http-client.spec.ts"
region="multi-request"
linenums="false">
-
### Testing for errors
@@ -1671,5 +1620,4 @@ Call `request.error()` with an `ErrorEvent` instead of `request.flush()`, as in
path="http/src/testing/http-client.spec.ts"
region="404"
linenums="false">
-
diff --git a/aio/content/guide/i18n.md b/aio/content/guide/i18n.md
index a9a365dbda..9ce2cab2b6 100644
--- a/aio/content/guide/i18n.md
+++ b/aio/content/guide/i18n.md
@@ -85,9 +85,7 @@ of the locale id that you want to use:
要把你的应用的地区改为其它值,可以使用 CLI 参数 `--locale` 来传入你要使用的地区标识:
-
ng serve --aot --locale fr
-
If you use JIT, you also need to define the `LOCALE_ID` provider in your main module:
@@ -95,7 +93,6 @@ If you use JIT, you also need to define the `LOCALE_ID` provider in your main mo
如果要使用 JIT,你就得在你的主模块中定义 `LOCALE_ID` 这个服务提供商:
-
For more information about Unicode locale identifiers, see the
@@ -150,7 +147,6 @@ If you want to import locale data for other languages, you can do it manually:
如果还要为其它语言导入本地化数据,你可以手工完成它:
-
The first parameter is an object containing the locale data imported from `@angular/common/locales`.
@@ -174,7 +170,6 @@ import from `@angular/common/locales/extra`. An error message informs you when t
不过有些高级的格式选项只存在于从 `@angular/common/locales/extra` 中导入的扩展数据集中。遇到这种情况,你就会收到一条错误信息。
-
@@ -243,7 +238,6 @@ In the example below, an `
` tag displays a simple English language greeting,
在下面的例子中,`
`标签显示了一句简单的英文问候语,“Hello i18n!”
-
To mark the greeting for translation, add the `i18n` attribute to the `
` tag.
@@ -251,7 +245,6 @@ To mark the greeting for translation, add the `i18n` attribute to the `
` tag
要想把它标记为需要翻译的文本,就给 `
` 标签添加上 `i18n` 属性。
-
@@ -280,7 +273,6 @@ example below:
你可以用 `i18n` 属性的值来添加这些文本信息的描述,例子如下:
-
The translator may also need to know the meaning or intent of the text message within this particular
@@ -294,7 +286,6 @@ separating it from the _description_ with the `|` character: `||<描述>`)。
-
All occurrences of a text message that have the same meaning will have the same translation.
@@ -323,7 +314,6 @@ attribute in a template. By default, it assigns each translation unit a unique i
Angular 的 `i18n` 提取工具会为模板中每个带有 `i18n` 属性的元素生成一个*翻译单元(translation unit)*条目,并保存到一个文件中。默认情况下,它为每个翻译单元指定一个唯一的 `id`,就像这样:
-
When you change the translatable text, the extractor tool generates a new id for that translation unit.
@@ -339,7 +329,6 @@ The example below defines the custom id `introductionHeader`:
下面这个例子就定义了一个自定义 id `introductionHeader`:
-
When you specify a custom id, the extractor tool and compiler generate a translation unit with that
@@ -348,7 +337,6 @@ custom id.
一旦你指定了自定义 id,提取工具和编译器就会用*你的自定义 id` 生成一个翻译单元,而不会再改变它。
-
The custom id is persistent. The extractor tool does not change it when the translatable text changes.
@@ -369,7 +357,6 @@ by the custom `id`:
下面的例子中,`i18n` 的属性中中就包含了一条跟在自定义 `id` 后面的描述信息:
-
You also can add a meaning, as shown in this example:
@@ -377,7 +364,6 @@ You also can add a meaning, as shown in this example:
你还可以添加含义,例子如下:
-
#### Define unique custom ids
@@ -446,7 +432,6 @@ The `` is transformed into an html comment:
但如果由于某些原因(比如 CSS 结构方面的考虑),你可能不希望仅仅为了翻译而创建一个新的 DOM 元素,那么也可以把这段文本包裹进一个 `` 元素中。`` 将被转换成一个 HTML 注释:
-
{@a translate-attributes}
@@ -462,7 +447,6 @@ For example, assume that your template has an image with a `title` attribute:
比如,假设你的模板中有一个带 `title` 属性的图片:
-
This `title` attribute needs to be translated.
@@ -477,7 +461,6 @@ where `x` is the name of the attribute to translate. The following example shows
下面的例子中演示了如何通过给 `img` 标签添加 `i18n-title` 属性来把 `title` 属性标记为待翻译的。
-
This technique works for any attribute of any element.
@@ -514,7 +497,6 @@ based on when the update occurred:
下面这个例子示范了如何使用 ICU 表达式 `plural` 来根据这次修改发生的时间显示这三个选项之一:
-
* The first parameter is the key. It is bound to the component property (`minutes`), which determines
@@ -620,7 +602,6 @@ The message maps those values to the appropriate translations:
这个消息会把那些值映射到适当的翻译文本:
-
{@a nesting-ICUS}
@@ -634,7 +615,6 @@ You can also nest different ICU expressions together, as shown in this example:
你也可以把不同的 ICU 表达式嵌套在一起,比如:
-
{@a ng-xi18n}
@@ -653,9 +633,7 @@ Open a terminal window at the root of the app project and enter the `ng xi18n` c
在应用的项目根目录打开一个终端窗口,并输入 `ng xi18n` 命令:
-
ng xi18n
-
By default, the tool generates a translation file named `messages.xlf` in the
@@ -711,11 +689,9 @@ these example commands:
你可以使用 `--i18nFormat` 来明确指定想用的格式,范例如下:
-
ng xi18n --i18nFormat=xlf
ng xi18n --i18nFormat=xlf2
ng xi18n --i18nFormat=xmb
-
The sample in this guide uses the default XLIFF 1.2 format.
@@ -870,7 +846,8 @@ This sample file is easy to translate without a special editor or knowledge of F
打开 `messages.fr.xlf` 并找到第一个 `` 区:
->
+>
+
> This XML element represents the translation of the `
` greeting tag that you marked with the
`i18n` attribute earlier in this guide.
@@ -891,13 +868,15 @@ This sample file is easy to translate without a special editor or knowledge of F
复制 `` 标记,把它改名为 `target`,并把它的内容改为法语版的 “greeting”。
如果你要做的是更复杂的翻译,可能会使用由源文本、描述信息和含义等提供的信息和上下文来给出更恰当的法语翻译。
->
+>
+
3. Translate the other text nodes the same way:
用同样的方式翻译其它文本节点:
->
+>
+
@@ -942,7 +921,6 @@ To translate a `plural`, translate its ICU format match values:
要翻译一个复数,就要翻译它的 ICU 格式中匹配的值:
-
You can add or remove plural cases, with each language having its own cardinality. (See
@@ -961,7 +939,6 @@ Below is the content of our example `select` ICU expression in the component tem
下面是组件模板中的 ICU 表达式 `select` 的例子:
-
The extraction tool broke that into two translation units because ICU expressions are extracted
@@ -980,7 +957,6 @@ the placeholder, the ICU expression will not be present in your translated app.
如果删除了占位符,ICU 表达式就不会出现在翻译后的应用中。
-
The second translation unit, immediately below the first one, contains the `select` message.
@@ -989,7 +965,6 @@ Translate that as well.
第一个翻译单元的紧下方就是第二个翻译单元,包含 `select` 中的消息。照样翻译它。
-
Here they are together, after translation:
@@ -997,7 +972,6 @@ Here they are together, after translation:
在翻译之后,它们会放在一起:
-
{@a translate-nested}
@@ -1013,7 +987,6 @@ two translation units. The first one contains the text outside of the nested exp
第一个包含嵌套表达式之外的文本:
-
The second unit contains the complete nested expression:
@@ -1021,7 +994,6 @@ The second unit contains the complete nested expression:
第二个包含完整的嵌套表达式:
-
And both together:
@@ -1029,7 +1001,6 @@ And both together:
放在一起时:
-
The entire template translation is complete. The next section describes how to load that translation
@@ -1048,7 +1019,6 @@ The sample app and its translation file are now as follows:
下面是例子应用及其翻译文件:
-
@@ -1059,7 +1029,6 @@ The sample app and its translation file are now as follows:
-
{@a merge}
@@ -1144,9 +1113,7 @@ guide:
下面的例子演示了如何使用前面部分创建的法语文件来启动开发服务器:
-
ng serve --aot --i18nFile=src/locale/messages.fr.xlf --i18nFormat=xlf --locale=fr
-
{@a merge-jit}
@@ -1196,7 +1163,6 @@ behavior of the compiler. You can use it to provide the translation providers:
在下面的 `src/app/i18n-providers.ts` 文件的 `getTranslationProviders()` 函数中,根据用户的**语言环境**和对应的翻译文件构建这些提供商:
-
Then provide the `LOCALE_ID` in the main module:
@@ -1204,7 +1170,6 @@ Then provide the `LOCALE_ID` in the main module:
然后在主文件包中提供 `LOCALE_ID`:
-
{@a missing-translation}
@@ -1238,9 +1203,7 @@ If you use the AOT compiler, specify the warning level by using the CLI paramete
如果你使用 AOT 编译器,可以使用 CLI 参数 `--missingTranslation` 来指定警告级别。下面的例子示范了如何把警告级别设置为 `error`:
-
ng serve --aot --missingTranslation=error
-
If you use the JIT compiler, specify the warning level in the compiler config at bootstrap by adding
@@ -1250,5 +1213,4 @@ error:
如果你要使用 JIT 编译器,就在启动时往编译器的配置中添加一个 `MissingTranslationStrategy` 属性来指定警告级别。下面的例子示范了如何把警告级别设置为 `error`:
-
diff --git a/aio/content/guide/language-service.md b/aio/content/guide/language-service.md
index 5981c53f09..4406f1298e 100644
--- a/aio/content/guide/language-service.md
+++ b/aio/content/guide/language-service.md
@@ -257,5 +257,4 @@ For more in-depth information, see the
For more information, see [Chuck Jazdzewski's presentation](https://www.youtube.com/watch?v=ez3R0Gi4z5A&t=368s) on the Angular Language
Service from [ng-conf](https://www.ng-conf.org/) 2017.
-
要了解更多信息,参见 [ng-conf](https://www.ng-conf.org/) 2017 中 [Chuck Jazdzewski 的演讲](https://www.youtube.com/watch?v=ez3R0Gi4z5A&t=368s) 中讲解的 Angular 语言服务。
diff --git a/aio/content/guide/lazy-loading-ngmodules.md b/aio/content/guide/lazy-loading-ngmodules.md
index 247674a6ac..1af45855e5 100644
--- a/aio/content/guide/lazy-loading-ngmodules.md
+++ b/aio/content/guide/lazy-loading-ngmodules.md
@@ -355,7 +355,7 @@ CLI 还会把 `RouterModule.forChild(routes)` 添加到各个特性模块中。
You may also be interested in the following:
-你可能还会对下列内容感兴趣:
+你可能还对下列内容感兴趣:
* [Routing and Navigation](guide/router).
@@ -363,8 +363,8 @@ You may also be interested in the following:
* [Providers](guide/providers).
- [提供商](guide/providers)。
+ [服务提供商](guide/providers)。
* [Types of Feature Modules](guide/module-types).
- [特性模块的分类](guide/module-types)。
+ [特性模块的分类](guide/module-types)。
diff --git a/aio/content/guide/lifecycle-hooks.md b/aio/content/guide/lifecycle-hooks.md
index 389d9ba8b0..ff17bce57b 100644
--- a/aio/content/guide/lifecycle-hooks.md
+++ b/aio/content/guide/lifecycle-hooks.md
@@ -62,7 +62,6 @@ calls the lifecycle hook methods in the following sequence at specific moments:
-
@@ -82,7 +81,6 @@ calls the lifecycle hook methods in the following sequence at specific moments:
-
@@ -106,7 +104,6 @@ calls the lifecycle hook methods in the following sequence at specific moments:
-
@@ -129,7 +126,6 @@ calls the lifecycle hook methods in the following sequence at specific moments:
-
@@ -151,7 +147,6 @@ calls the lifecycle hook methods in the following sequence at specific moments:
-
@@ -173,7 +168,6 @@ calls the lifecycle hook methods in the following sequence at specific moments:
-
@@ -195,7 +189,6 @@ calls the lifecycle hook methods in the following sequence at specific moments:
-
@@ -217,7 +210,6 @@ calls the lifecycle hook methods in the following sequence at specific moments:
-
@@ -239,7 +231,6 @@ calls the lifecycle hook methods in the following sequence at specific moments:
-
@@ -263,7 +254,6 @@ calls the lifecycle hook methods in the following sequence at specific moments:
-
{@a interface-optional}
@@ -335,7 +325,6 @@ Here's a brief description of each exercise:
-
@@ -355,7 +344,6 @@ Here's a brief description of each exercise:
-
@@ -374,7 +362,6 @@ Here's a brief description of each exercise:
-
@@ -399,7 +386,6 @@ Here's a brief description of each exercise:
-
@@ -420,7 +406,6 @@ Here's a brief description of each exercise:
-
@@ -440,7 +425,6 @@ Here's a brief description of each exercise:
-
@@ -460,7 +444,6 @@ Here's a brief description of each exercise:
-
@@ -481,7 +464,6 @@ Here's a brief description of each exercise:
-
@@ -510,7 +492,6 @@ Here's a brief description of each exercise:
-
The remainder of this page discusses selected exercises in further detail.
diff --git a/aio/content/guide/module-types.md b/aio/content/guide/module-types.md
index 1eda0edb22..6c0ecfaf68 100644
--- a/aio/content/guide/module-types.md
+++ b/aio/content/guide/module-types.md
@@ -115,7 +115,6 @@ typical characteristics, in real world apps, you may see hybrids.
-
@@ -299,7 +298,6 @@ The following table summarizes the key characteristics of each feature module gr
下表中汇总了各种特性模块类型的关键特征。
-
@@ -559,7 +557,6 @@ The following table summarizes the key characteristics of each feature module gr
-
@@ -570,7 +567,7 @@ The following table summarizes the key characteristics of each feature module gr
You may also be interested in the following:
-你可能还会对下列内容感兴趣:
+你可能还对下列内容感兴趣:
* [Lazy Loading Modules with the Angular Router](guide/lazy-loading-ngmodules).
@@ -578,4 +575,4 @@ You may also be interested in the following:
* [Providers](guide/providers).
- [服务提供商](guide/providers)。
+ [服务提供商](guide/providers)。
diff --git a/aio/content/guide/ngmodule-api.md b/aio/content/guide/ngmodule-api.md
index 7107a5e1c4..d0f71fa10a 100644
--- a/aio/content/guide/ngmodule-api.md
+++ b/aio/content/guide/ngmodule-api.md
@@ -139,7 +139,9 @@ The following table summarizes the `@NgModule` metadata properties.
+
+
Components, directives, and pipes must belong to _exactly_ one module.
@@ -402,8 +404,8 @@ You may also be interested in the following:
* [Providers](guide/providers).
- [提供商](guide/providers)。
+ [服务提供商](guide/providers)。
* [Types of Feature Modules](guide/module-types).
- [特性模块的分类](guide/module-types)。
+ [特性模块的分类](guide/module-types)。
diff --git a/aio/content/guide/ngmodule-faq.md b/aio/content/guide/ngmodule-faq.md
index a55b36bd5d..b9c7244961 100644
--- a/aio/content/guide/ngmodule-faq.md
+++ b/aio/content/guide/ngmodule-faq.md
@@ -803,7 +803,6 @@ Here is a custom constructor for an NgModule called `CoreModule`.
某些 Angular 模块(例如 `BrowserModule`)就实现了一个像 Angular 模块那一章的 `CoreModule` 构造函数那样的守卫。
-
@@ -1133,5 +1132,4 @@ the Angular compiler incorporates them into compiled component code too.
`@NgModule` metadata tells the Angular compiler what components to compile for this module and
how to link this module with other modules.
-
`@NgModule` 元数据告诉*Angular 编译器*要为当前模块编译哪些组件,以及如何把当前模块和其它模块链接起来。
diff --git a/aio/content/guide/ngmodule-vs-jsmodule.md b/aio/content/guide/ngmodule-vs-jsmodule.md
index 29fbb9e4b7..ab2b107d47 100644
--- a/aio/content/guide/ngmodule-vs-jsmodule.md
+++ b/aio/content/guide/ngmodule-vs-jsmodule.md
@@ -126,4 +126,4 @@ For more information on NgModules, see:
* [Providers](guide/providers).
- [服务提供商](guide/providers).
+ [服务提供商](guide/providers)。
diff --git a/aio/content/guide/ngmodules.md b/aio/content/guide/ngmodules.md
index c33fc25759..3ac115a7cf 100644
--- a/aio/content/guide/ngmodules.md
+++ b/aio/content/guide/ngmodules.md
@@ -121,7 +121,6 @@ The CLI generates the following basic app module when creating a new app.
CLI 在创建新应用时会生成下列基本的应用模块。
-
At the top are the import statements. The next section is where you configure the `@NgModule` by stating what components and directives belong to it (`declarations`) as well as which other modules it uses (`imports`). This page builds on [Bootstrapping](guide/bootstrapping), which covers the structure of an NgModule in detail. If you need more information on the structure of an `@NgModule`, be sure to read [Bootstrapping](guide/bootstrapping).
@@ -137,7 +136,7 @@ At the top are the import statements. The next section is where you configure th
You may also be interested in the following:
-你可能还会对下列内容感兴趣:
+你可能还对下列内容感兴趣:
* [Feature Modules](guide/feature-modules).
@@ -149,8 +148,8 @@ You may also be interested in the following:
* [Providers](guide/providers).
- [提供商](guide/providers)。
+ [服务提供商](guide/providers)。
* [Types of NgModules](guide/module-types).
- [NgModule 的分类](guide/module-types).
+ [NgModule 的分类](guide/module-types).
diff --git a/aio/content/guide/npm-packages.md b/aio/content/guide/npm-packages.md
index 7239c01ce3..88e6e1d285 100644
--- a/aio/content/guide/npm-packages.md
+++ b/aio/content/guide/npm-packages.md
@@ -280,5 +280,4 @@ The browser downloads this bundle, not the original package files.
See the [Deployment](guide/deployment) to learn more.
-
参见[部署](guide/deployment)一章了解详情。
diff --git a/aio/content/guide/observables.md b/aio/content/guide/observables.md
index ce04c3e7fa..bdcbae5d55 100644
--- a/aio/content/guide/observables.md
+++ b/aio/content/guide/observables.md
@@ -52,11 +52,11 @@ A handler for receiving observable notifications implements the `Observer` inter
用于接收可观察对象通知的处理器要实现 `Observer` 接口。这个对象定义了一些回调函数来处理可观察对象可能会发来的三种通知:
-|
Required. A handler for each delivered value. Called zero or more times after execution starts.
必要。用来处理每个送达值。在开始执行后可能执行零次或多次。
|
-| `error` |
Optional. A handler for an error notification. An error halts execution of the observable instance.
可选。用来处理错误通知。错误会中断这个可观察对象实例的执行过程。
|
-| `complete` |
Optional. A handler for the execution-complete notification. Delayed values can continue to be delivered to the next handler after execution is complete.
可选。用来处理执行完毕(complete)通知。当执行完毕后,这些值就会继续传给下一个处理器。
|
+| `next` | Required. A handler for each delivered value. Called zero or more times after execution starts.必要。用来处理每个送达值。在开始执行后可能执行零次或多次。|
+| `error` | Optional. A handler for an error notification. An error halts execution of the observable instance. 可选。用来处理错误通知。错误会中断这个可观察对象实例的执行过程。 |
+| `complete` | Optional. A handler for the execution-complete notification. Delayed values can continue to be delivered to the next handler after execution is complete. 可选。用来处理执行完毕(complete)通知。当执行完毕后,这些值就会继续传给下一个处理器。 |
An observer object can define any combination of these handlers. If you don't supply a handler for a notification type, the observer ignores notifications of that type.
@@ -107,7 +107,7 @@ In either case, a `next` handler is required. The `error` and `complete` handler
无论哪种情况,`next` 处理器都是必要的,而 `error` 和 `complete` 处理器是可选的。
-Note that a `next()` function could receive, for instance, message strings, or event objects, numeric values, or structures, depending on context. As a general term, we refer to data published by an observable as a *stream*. Any type of value can be represented with an observable, and the values are published as a stream.
+Note that a `next()` function could receive, for instance, message strings, or event objects, numeric values, or stuctures, depending on context. As a general term, we refer to data published by an observable as a *stream*. Any type of value can be represented with an observable, and the values are published as a stream.
注意,`next()` 函数可以接受消息字符串、事件对象、数字值或各种结构,具体类型取决于上下文。
为了更通用一点,我们把由可观察对象发布出来的数据统称为*流*。任何类型的值都可以表示为可观察对象,而这些值会被发布为一个流。
@@ -196,12 +196,10 @@ Because observables produce values asynchronously, try/catch will not effectivel
由于可观察对象会异步生成值,所以用 `try/catch` 是无法捕获错误的。你应该在观察者中指定一个 `error` 回调来处理错误。发生错误时还会导致可观察对象清理现有的订阅,并且停止生成值。可观察对象可以生成值(调用 `next` 回调),也可以调用 `complete` 或 `error` 回调来主动结束。
-
myObservable.subscribe({
next(num) { console.log('Next num: ' + num)},
error(err) { console.log('Received an errror: ' + err)}
});
-
Error handling (and specifically recovering from an error) is covered in more detail in a later section.
diff --git a/aio/content/guide/pipes.md b/aio/content/guide/pipes.md
index 7385c1fbd5..1223032457 100644
--- a/aio/content/guide/pipes.md
+++ b/aio/content/guide/pipes.md
@@ -32,7 +32,7 @@ Introducing Angular pipes, a way to write display-value transformations that you
You can run the in Stackblitz and download the code from there.
-运行来试用本页的代码。
+你可以运行,在 Stackblitz 中试用并下载本页的代码。
## Using pipes
@@ -249,7 +249,6 @@ Now you need a component to demonstrate the pipe.
现在,你需要一个组件来演示这个管道。
-
@@ -780,10 +779,8 @@ The list might be sorted by hero `name` and `planet` of origin properties in the
虽然不是很明显,但代码最小化方面也存在风险。想象一个用于英雄列表的排序管道。该列表可能根据英雄原始属性中的 `name` 和 `planet` 进行排序,就像这样:
-
<!-- NOT REAL CODE! -->
<div *ngFor="let hero of heroes | orderBy:'name,planet'"></div>
-
You identify the sort fields by text strings, expecting the pipe to reference a property value by indexing
@@ -817,5 +814,4 @@ Angular 开发组和一些有经验的 Angular 开发者强烈建议你:把你
If these performance and minification considerations don't apply to you, you can always create your own such pipes
(similar to the [FlyingHeroesPipe](guide/pipes#impure-flying-heroes)) or find them in the community.
-
如果你不需要顾虑这些性能和最小化问题,也可以创建自己的管道来实现这些功能(参考[FlyingHeroesPipe](guide/pipes#impure-flying-heroes)中的写法)或到社区中去找找。
diff --git a/aio/content/guide/providers.md b/aio/content/guide/providers.md
index 087b7574ab..cfce752754 100644
--- a/aio/content/guide/providers.md
+++ b/aio/content/guide/providers.md
@@ -12,7 +12,7 @@
* Familiarity with [Frequently Used Modules](guide/frequent-ngmodules).
- 熟悉[常用模块](guide/frequent-ngmodules).
+ 熟悉[常用模块](guide/frequent-ngmodules)。
For the final sample app using the provider that this page describes,
see the .
@@ -45,7 +45,6 @@ of the file and adding it to the `providers` array:
这将会创建一个名叫 `UserService` 的服务。你现在要让该服务在你的应用注入器中可用,就要修改 `app.module.ts` 文件。先在文件的顶部导入它,然后把它加入 `providers` 数组中:
-
## Provider scope
@@ -101,7 +100,6 @@ the same module can’t access it.)
在组件中提供服务,会限定该服务只能在该组件中有效(同一模块中的其它组件不能访问它)。
-
## Providing services in modules vs. components
@@ -132,7 +130,7 @@ Register a provider with a component when you must limit a service instance to a
You may also be interested in:
-你可能还对下列内容感兴趣:
+你还可能对下列内容感兴趣:
* [Singleton Services](guide/singleton-services), which elaborates on the concepts covered on this page.
@@ -140,8 +138,8 @@ You may also be interested in:
* [Lazy Loading Modules](guide/lazy-loading-ngmodules).
- [惰性加载模块](guide/lazy-loading-ngmodules).
+ [惰性加载模块](guide/lazy-loading-ngmodules)。
* [NgModule FAQ](guide/ngmodule-faq).
- [NgModule 常见问题](guide/ngmodule-faq)。
+ [NgModule 常见问题](guide/ngmodule-faq)。
diff --git a/aio/content/guide/quickstart.md b/aio/content/guide/quickstart.md
index 583e83f6bc..7875c10ad9 100644
--- a/aio/content/guide/quickstart.md
+++ b/aio/content/guide/quickstart.md
@@ -59,7 +59,6 @@ Then **install the [Angular CLI](https://github.com/angular/angular-cli)** globa
然后全局安装 **[Angular CLI](https://github.com/angular/angular-cli)** 。
-
npm install -g @angular/cli
@@ -77,7 +76,6 @@ Generate a new project and skeleton application by running the following command
运行下列命令来生成一个新项目以及应用的骨架代码:
-
ng new my-app
@@ -101,10 +99,8 @@ Go to the project directory and launch the server.
进入项目目录,并启动服务器。
-
cd my-app
ng serve --open
-
The `ng serve` command launches the server, watches your files,
@@ -282,7 +278,6 @@ Any files outside of this folder are meant to support building your app.
-
@@ -302,7 +297,6 @@ Any files outside of this folder are meant to support building your app.
-
@@ -323,7 +317,6 @@ Any files outside of this folder are meant to support building your app.
-
@@ -345,7 +338,6 @@ Any files outside of this folder are meant to support building your app.
-
@@ -364,7 +356,6 @@ Any files outside of this folder are meant to support building your app.
-
@@ -385,14 +376,13 @@ Any files outside of this folder are meant to support building your app.
这个文件夹中包括为各个目标环境准备的文件,它们导出了一些应用中要用到的配置变量。
这些文件会在构建应用时被替换。
- 比如你可能在产品环境中使用不同的 API 端点地址,或使用不同的统计 Token 参数。
+ 比如你可能在生产环境中使用不同的 API 端点地址,或使用不同的统计 Token 参数。
甚至使用一些模拟服务。
所有这些,CLI 都替你考虑到了。
-
@@ -412,7 +402,6 @@ Any files outside of this folder are meant to support building your app.
-
@@ -435,7 +424,6 @@ Any files outside of this folder are meant to support building your app.
-
@@ -459,7 +447,6 @@ Any files outside of this folder are meant to support building your app.
-
@@ -482,7 +469,6 @@ Any files outside of this folder are meant to support building your app.
-
@@ -503,7 +489,6 @@ Any files outside of this folder are meant to support building your app.
-
@@ -524,7 +509,6 @@ Any files outside of this folder are meant to support building your app.
-
@@ -543,7 +527,6 @@ Any files outside of this folder are meant to support building your app.
-
### The root folder
@@ -610,7 +593,6 @@ These files go in the root folder next to `src/`.
-
@@ -625,12 +607,11 @@ These files go in the root folder next to `src/`.
Purpose
- 目的
+ 用途
-
@@ -653,7 +634,6 @@ These files go in the root folder next to `src/`.
-
@@ -672,7 +652,6 @@ These files go in the root folder next to `src/`.
-
@@ -695,7 +674,6 @@ These files go in the root folder next to `src/`.
-
@@ -717,7 +695,6 @@ These files go in the root folder next to `src/`.
-
@@ -735,7 +712,6 @@ These files go in the root folder next to `src/`.
-
@@ -754,7 +730,6 @@ These files go in the root folder next to `src/`.
-
@@ -774,7 +749,6 @@ These files go in the root folder next to `src/`.
-
@@ -793,7 +767,6 @@ These files go in the root folder next to `src/`.
-
@@ -814,7 +787,6 @@ These files go in the root folder next to `src/`.
-
@@ -832,7 +804,6 @@ These files go in the root folder next to `src/`.
-
@@ -853,7 +824,6 @@ These files go in the root folder next to `src/`.
-
diff --git a/aio/content/guide/reactive-forms.md b/aio/content/guide/reactive-forms.md
index a9f94b2f34..9c08299bf4 100644
--- a/aio/content/guide/reactive-forms.md
+++ b/aio/content/guide/reactive-forms.md
@@ -427,7 +427,7 @@ This guide uses four fundamental classes to build a reactive form:
`FormControl`, `FormGroup`, and `FormArray`.
It provides their common behaviors and properties.
- [`AbstractControl`](api/forms/AbstractControl "API Reference: FormControl")是这三个具体表单类的抽象基类。
+ [`AbstractControl`](api/forms/AbstractControl "API Reference: FormControl")是这三个具体表单类的抽象基类。
并为它们提供了一些共同的行为和属性。
@@ -1156,7 +1156,6 @@ which is covered in the section on [`FormArray`](guide/reactive-forms#form-array
`Hero` 有一个住址数组。这个表单模型只表示了一个住址,稍后的 [`FormArray`] (guide/reactive-forms#form-array "Form arrays")则可以表示多个。
-
Keeping the two models close in shape facilitates copying the data model properties
to the form model with the `patchValue()` and `setValue()` methods in the next section.
diff --git a/aio/content/guide/router.md b/aio/content/guide/router.md
index 97df7dce7d..c9f3631a14 100644
--- a/aio/content/guide/router.md
+++ b/aio/content/guide/router.md
@@ -214,7 +214,6 @@ _after_ a `RouterOutlet` that you've placed in the host view's HTML.
有了这份配置,当本应用在浏览器中的 URL 变为 `/heroes` 时,路由器就会匹配到 `path` 为 `heroes` 的 `Route`,并在宿主视图中的*`RouterOutlet`*之后显示 `HeroListComponent` 组件。
-
<router-outlet></router-outlet>
<!-- Routed views go here -->
@@ -294,7 +293,6 @@ It has a great deal of useful information including:
它有一大堆有用的信息,包括:
-
@@ -496,7 +494,6 @@ It has a great deal of useful information including:
-
@@ -525,7 +522,6 @@ During each navigation, the `Router` emits navigation events through the `Router
在每次导航中,`Router` 都会通过 `Router.events` 属性发布一些导航事件。这些事件的范围涵盖了从开始导航到结束导航之间的很多时间点。下表中列出了全部导航事件:
-
@@ -674,7 +670,6 @@ During each navigation, the `Router` emits navigation events through the `Router
-
These events are logged to the console when the `enableTracing` option is enabled also. Since the events are provided as an `Observable`, you can `filter()` for events of interest and `subscribe()` to them to make decisions based on the sequence of events in the navigation process.
@@ -748,8 +743,6 @@ Here are the key `Router` terms and their meanings:
RouterModule
- RouterModule(路由器模块)
-
@@ -1218,7 +1211,6 @@ That's why the example code replaces the `` with a script that wri
这就是为什么范例代码中要用一个脚本动态写入 `` 标签,而不是直接写 ``。
-
<script>document.write('<base href="' + document.location + '" />');</script>
@@ -1344,7 +1336,7 @@ The corresponding component template looks like this:
### *RouterOutlet*
-### *RouterOutlet* 指令
+### 路由出口
The `RouterOutlet` is a directive from the router library that marks
the spot in the template where the router should display the views for that outlet.
@@ -1525,9 +1517,7 @@ When the application launches, the initial URL in the browser bar is something l
应用启动时,浏览器地址栏中的初始 URL 是这样的:
-
localhost:3000
-
That doesn't match any of the concrete configured routes which means
@@ -1560,7 +1550,6 @@ It's just above the wildcard route in the following excerpt showing the complete
在下方的代码片段中,它出现在通配符路由的紧上方,展示了这个里程碑的完整 `appRoutes`。
-
A redirect route requires a `pathMatch` property to tell the router how to match a URL to the path of a route.
@@ -2361,7 +2350,6 @@ you expect a hero id to appear in the browser URL like this:
如果要告诉路由器导航到详情组件,并让它显示“Magneta”,你会期望这个英雄的 `id` 像这样显示在浏览器的 URL 中:
-
localhost:3000/hero/15
@@ -2505,7 +2493,6 @@ to handle parameter access for both route parameters (`paramMap`) and query para
`ParamMap` API 是参照[URLSearchParams 接口](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)来设计的。它提供了一些方法来处理对路由参数(`paramMap`)和查询参数(`queryParamMap`)中的参数访问。
-
@@ -2597,7 +2584,6 @@ to handle parameter access for both route parameters (`paramMap`) and query para
-
{@a reuse}
@@ -2745,7 +2731,6 @@ as you do when navigating to the `HeroDetailComponent` in order to view the hero
如果想导航到 `HeroDetailComponent` 以对 id 为 15 的英雄进行查看并编辑,就要在路由的 URL 中使用[*路由参数*](guide/router#route-parameters)来指定*必要*参数值。
-
localhost:3000/hero/15
@@ -2866,7 +2851,6 @@ It should look something like this, depending on where you run it:
它应该是这样的,不过也取决于你在哪里运行它:
-
localhost:3000/heroes;id=15;foo=foo
@@ -3413,7 +3397,6 @@ Add the following `crisis-center.component.ts` to the `crisis-center` folder:
往 `crisis-center` 目录下添加下列 `crisis-center.component.ts` 文件:
-
The `CrisisCenterComponent` has the following in common with the `AppComponent`:
@@ -3455,7 +3438,6 @@ As a host page for the "Crisis Center" feature, add the following `crisis-center
把下面这个 `crisis-center-home.component.ts` 添加到 `crisis-center` 目录下,作为 "危机中心" 特性区的宿主页面。
-
Create a `crisis-center-routing.module.ts` file as you did the `heroes-routing.module.ts` file.
@@ -3465,7 +3447,6 @@ This time, you define **child routes** *within* the parent `crisis-center` route
但这次,你要把**子路由**定义在父路由 `crisis-center` 中。
-
Notice that the parent `crisis-center` route has a `children` property
@@ -3529,7 +3510,6 @@ The absolute URL for the latter example, including the `localhost` origin, is
本例子中包含站点部分的绝对 URL,就是:
-
localhost:3000/crisis-center/2
@@ -3882,7 +3862,6 @@ you should see something like the following URL in the browser address bar.
导航到*危机中心*并点击“Contact”,你将会在浏览器的地址栏看到如下 URL:
-
http://.../crisis-center(popup:compose)
@@ -3908,9 +3887,7 @@ Click the _Heroes_ link and look at the URL again.
点击 *Heroes* 链接,并再次查看 URL:
-
http://.../heroes(popup:compose)
-
The primary navigation part has changed; the secondary route is the same.
@@ -5723,7 +5700,6 @@ Here's the *Crisis Center* URL in this "HTML5 pushState" style:
下面是*危机中心*的 URL 在“HTML 5 pushState”风格下的样子:
-
localhost:3002/crisis-center/
@@ -5736,7 +5712,6 @@ URLs with hashes. Here's a "hash URL" that routes to the *Crisis Center*.
老旧的浏览器在当前地址的 URL 变化时总会往服务器发送页面请求……唯一的例外规则是:当这些变化位于“#”(被称为“hash”)后面时不会发送。通过把应用内的路由 URL 拼接在 `#` 之后,路由器可以获得这条“例外规则”带来的优点。下面是到*危机中心*路由的“hash URL”:
-
localhost:3002/src/#/crisis-center/
diff --git a/aio/content/guide/security.md b/aio/content/guide/security.md
index 2e8e7ed00e..7f0f2a351c 100644
--- a/aio/content/guide/security.md
+++ b/aio/content/guide/security.md
@@ -15,7 +15,7 @@ For more information about the attacks and mitigations described below, see [OWA
You can run the in Stackblitz and download the code from there.
-运行来试用本页的代码。
+你可以运行,在 Stackblitz 中试用并下载本页的代码。
Reporting vulnerabilities
@@ -426,6 +426,5 @@ must be audited as such. Angular-specific APIs that should be audited in a secur
such as the [_bypassSecurityTrust_](guide/security#bypass-security-apis) methods, are marked in the documentation
as security sensitive.
-
Angular 应用应该遵循和常规 Web 应用一样的安全原则并按照这些原则进行审计。Angular 中某些应该在安全评审中被审计的 API(
比如[_bypassSecurityTrust_](guide/security#bypass-security-apis) API)都在文档中被明确标记为安全性敏感的。
diff --git a/aio/content/guide/service-worker-communications.md b/aio/content/guide/service-worker-communications.md
index d6e2938003..67970434df 100644
--- a/aio/content/guide/service-worker-communications.md
+++ b/aio/content/guide/service-worker-communications.md
@@ -16,7 +16,7 @@ A basic understanding of the following:
* [Getting Started with Service Workers](guide/service-worker-getting-started).
- [Service Worker 快速起步](guide/service-worker-getting-started).
+ [Service Worker 快速起步](guide/service-worker-getting-started)。
@@ -101,8 +101,8 @@ Doing this could break lazy-loading into currently running apps, especially if t
You may also be interested in the following:
-你可能对下列内容感兴趣:
+你可能还对下列内容感兴趣:
* [Service Worker in Production](guide/service-worker-devops).
- [产品环境下的 Service Worker](guide/service-worker-devops).
+ [生产环境下的 Service Worker](guide/service-worker-devops)。
diff --git a/aio/content/guide/service-worker-config.md b/aio/content/guide/service-worker-config.md
index 4c1317c652..5837add98f 100644
--- a/aio/content/guide/service-worker-config.md
+++ b/aio/content/guide/service-worker-config.md
@@ -14,7 +14,7 @@ A basic understanding of the following:
* [Service Worker in Production](guide/service-worker-devops).
- [产品环境下的 Service Worker](guide/service-worker-devops).
+ [生产环境下的 Service Worker](guide/service-worker-devops)。
@@ -313,5 +313,4 @@ Angular Service Worker 可以使用两种缓存策略之一来获取数据资源
* `freshness` optimizes for currency of data, preferentially fetching requested data from the network. Only if the network times out, according to `timeout`, does the request fall back to the cache. This is useful for resources that change frequently; for example, account balances.
- `freshness` 为数据的即时性而优化,优先从网络获取请求的数据。只有当网络超时时,请求才会根据 `timeout` 的设置回退到缓存中。这对于那些频繁变化的资源很有用,例如账户余额。
-
\ No newline at end of file
+ `freshness` 为数据的即时性而优化,优先从网络获取请求的数据。只有当网络超时时,请求才会根据 `timeout` 的设置回退到缓存中。这对于那些频繁变化的资源很有用,例如账户余额。
diff --git a/aio/content/guide/service-worker-devops.md b/aio/content/guide/service-worker-devops.md
index 2ea8ab8650..db42bcd6e7 100644
--- a/aio/content/guide/service-worker-devops.md
+++ b/aio/content/guide/service-worker-devops.md
@@ -1,11 +1,11 @@
# Service worker in production
-# 产品环境下的 Service Worker
+# 生产环境下的 Service Worker
This page is a reference for deploying and supporting production apps that use the Angular service worker. It explains how the Angular service worker fits into the larger production environment, the service worker's behavior under various conditions, and available recourses and fail-safes.
-本页讲的是如何使用 Angular Service Worker 发布和支持产品环境下的应用。
-它解释了 Angular Service Worker 如何满足大规模产品环境的需求、Service Worker 在多种条件下有哪些行为以及有哪些可用的资源和故障保护机制。
+本页讲的是如何使用 Angular Service Worker 发布和支持生产环境下的应用。
+它解释了 Angular Service Worker 如何满足大规模生产环境的需求、Service Worker 在多种条件下有哪些行为以及有哪些可用的资源和故障保护机制。
#### Prerequisites
@@ -557,8 +557,8 @@ the past on your site.
You may also be interested in the following:
-你可能对下列内容感兴趣:
+你可能还对下列内容感兴趣:
* [Service Worker Configuration](guide/service-worker-config).
- [Service Worker 配置](guide/service-worker-config).
+ [Service Worker 配置](guide/service-worker-config)。
diff --git a/aio/content/guide/service-worker-getting-started.md b/aio/content/guide/service-worker-getting-started.md
index 3d0a92c075..e27c8f93cd 100644
--- a/aio/content/guide/service-worker-getting-started.md
+++ b/aio/content/guide/service-worker-getting-started.md
@@ -120,7 +120,7 @@ At the top of the root module, `src/app/app.module.ts`, import `ServiceWorkerMod
Add `ServiceWorkerModule` to the `@NgModule` `imports` array. Use the `register()` helper to take care of registering the service worker, taking care to disable the service worker when not running in production mode.
-把 `ServiceWorkerModule` 添加到 `@NgModule` 的 `imports` 数组中。使用 `register()` 来帮助管理 Service Worker 的注册并在非产品环境下运行时禁用 Service Worker。
+把 `ServiceWorkerModule` 添加到 `@NgModule` 的 `imports` 数组中。使用 `register()` 来帮助管理 Service Worker 的注册并在非生产环境下运行时禁用 Service Worker。
@@ -367,8 +367,8 @@ Service Worker *在后台*安装好了这个更新后的版本,下次加载或
You may also be interested in the following:
-你可能对下列内容感兴趣:
+你可能还对下列内容感兴趣:
* [Communicating with service workers](guide/service-worker-communications).
- [与 Service Worker 通讯](guide/service-worker-communications).
+ [与 Service Worker 通讯](guide/service-worker-communications)。
diff --git a/aio/content/guide/service-worker-intro.md b/aio/content/guide/service-worker-intro.md
index e0540816e5..6d78ff26dc 100644
--- a/aio/content/guide/service-worker-intro.md
+++ b/aio/content/guide/service-worker-intro.md
@@ -122,8 +122,8 @@ The remainder of this Angular documentation specifically addresses the Angular i
You may also be interested in the following:
-你可能还会对下列内容感兴趣:
+你可能还对下列内容感兴趣:
* [Getting Started with service workers](guide/service-worker-getting-started).
- [Service Worker 快速起步](guide/service-worker-getting-started).
+ [Service Worker 快速起步](guide/service-worker-getting-started)。
diff --git a/aio/content/guide/set-document-title.md b/aio/content/guide/set-document-title.md
index eadb6b71c3..4edd614068 100644
--- a/aio/content/guide/set-document-title.md
+++ b/aio/content/guide/set-document-title.md
@@ -22,9 +22,7 @@ The obvious approach is to bind a property of the component to the HTML `
显而易见的方法是把组件的属性绑定到 HTML 的 `` 标签上,像这样:
-
<title>{{This_Does_Not_Work}}</title>
-
Sorry but that won't work.
@@ -89,11 +87,9 @@ Here's the complete solution:
这里是完整的方案(代码)。
-
-
## Why provide the `Title` service in `bootstrap`
@@ -116,5 +112,4 @@ you'll have to provide a different `Title` service that understands
the concept of a "document title" for that specific platform.
Ideally, the application itself neither knows nor cares about the runtime environment.
-
你的做法正是如此。这里的 `Title` 服务是 Angular*浏览器平台*的一部分。如果在其它平台上引导应用程序,就得提供另一个专为那个平台准备的 `Title` 服务。
diff --git a/aio/content/guide/setup-systemjs-anatomy.md b/aio/content/guide/setup-systemjs-anatomy.md
index 1790e52cbb..456ff25612 100644
--- a/aio/content/guide/setup-systemjs-anatomy.md
+++ b/aio/content/guide/setup-systemjs-anatomy.md
@@ -394,9 +394,7 @@ If you do, this page can help you understand their purpose.
为 **SystemJS** 模块加载器指定去哪儿查找在 JavaScript 的 `import` 语句中引用的模块。例如:
-
import { Component } from '@angular/core;
-
Don't touch this file unless you are fully versed in SystemJS configuration.
diff --git a/aio/content/guide/setup.md b/aio/content/guide/setup.md
index 29f5cfbd75..beddeef79e 100644
--- a/aio/content/guide/setup.md
+++ b/aio/content/guide/setup.md
@@ -32,7 +32,6 @@ Perform the _clone-to-launch_ steps with these terminal commands.
运行下列命令来执行*克隆并启动*步骤。
-
git clone https://github.com/angular/quickstart.git quickstart
cd quickstart
npm install
@@ -61,7 +60,6 @@ and unzip it into your project folder. Then perform the remaining steps with the
并解压到你的项目目录中。然后执行下面的命令完成剩余步骤。
-
cd quickstart
npm install
npm start
@@ -103,7 +101,6 @@ Open a terminal window in the project folder and enter the following commands fo
### OS/X (bash)
-
xargs rm -rf < non-essential-files.osx.txt
rm src/app/*.spec*.ts
rm non-essential-files.osx.txt
@@ -113,7 +110,6 @@ Open a terminal window in the project folder and enter the following commands fo
### Windows
-
for /f %i in (non-essential-files.txt) do del %i /F /S /Q
rd .git /s /q
rd e2e /s /q
diff --git a/aio/content/guide/sharing-ngmodules.md b/aio/content/guide/sharing-ngmodules.md
index 7ed56370d1..18b4f3cc39 100644
--- a/aio/content/guide/sharing-ngmodules.md
+++ b/aio/content/guide/sharing-ngmodules.md
@@ -28,7 +28,7 @@ A basic understanding of the following:
* [Lazy loading modules](guide/lazy-loading-ngmodules).
- [惰性加载模块](guide/lazy-loading-ngmodules).
+ [惰性加载模块](guide/lazy-loading-ngmodules)。
@@ -123,12 +123,12 @@ To read about sharing services, see [Providers](guide/providers).
You may also be interested in the following:
-你可能还会对下列内容感兴趣:
+你可能还对下列内容感兴趣:
* [Providers](guide/providers).
- [提供商](guide/providers)。
+ [服务提供商](guide/providers)。
* [Types of Feature Modules](guide/module-types).
- [特性模块的分类](guide/module-types).
+ [特性模块的分类](guide/module-types)。
diff --git a/aio/content/guide/singleton-services.md b/aio/content/guide/singleton-services.md
index 36c9e0de5f..e06158b362 100644
--- a/aio/content/guide/singleton-services.md
+++ b/aio/content/guide/singleton-services.md
@@ -44,7 +44,6 @@ a way of providing services from a designated NgModule.
下面的范例模块习惯上叫做 `CoreModule`。`@NgModule` 用来创建结构良好的基础设施,让你能够在一个指定的模块中提供服务。
-
Here, `CoreModule` provides the `UserService`, and because `AppModule`
@@ -269,7 +268,6 @@ Here are the two files in their entirety for reference:
以下这两个文件仅供参考:
-
@@ -279,7 +277,6 @@ Here are the two files in their entirety for reference:
region="whole-core-module"
path="ngmodules/src/app/core/core.module.ts">
-
@@ -298,8 +295,8 @@ You may also be interested in:
* [Lazy Loading Modules](guide/lazy-loading-ngmodules).
- [惰性加载模块](guide/lazy-loading-ngmodules).
+ [惰性加载模块](guide/lazy-loading-ngmodules)。
* [NgModule FAQ](guide/ngmodule-faq).
- [NgModule 常见问题](guide/ngmodule-faq)。
+ [NgModule 常见问题](guide/ngmodule-faq)。
diff --git a/aio/content/guide/structural-directives.md b/aio/content/guide/structural-directives.md
index ca5d118b00..4a128c7966 100644
--- a/aio/content/guide/structural-directives.md
+++ b/aio/content/guide/structural-directives.md
@@ -723,7 +723,6 @@ It's more like the curly braces in a JavaScript `if`-block:
它不是一个指令、组件、类或接口,更像是 JavaScript 中 `if` 块中的花括号。
-
if (someCondition) {
statement1;
statement2;
diff --git a/aio/content/guide/styleguide.md b/aio/content/guide/styleguide.md
index e748f1d639..b9bb9353fb 100644
--- a/aio/content/guide/styleguide.md
+++ b/aio/content/guide/styleguide.md
@@ -509,10 +509,8 @@ and reference assets of different types.
-
@Component({ ... })
export class AppComponent { }
-
@@ -530,10 +528,8 @@ and reference assets of different types.
-
@Component({ ... })
export class HeroesComponent { }
-
@@ -551,10 +547,8 @@ and reference assets of different types.
-
@Component({ ... })
export class HeroListComponent { }
-
@@ -572,10 +566,8 @@ and reference assets of different types.
-
@Component({ ... })
export class HeroDetailComponent { }
-
@@ -593,10 +585,8 @@ and reference assets of different types.
-
@Directive({ ... })
export class ValidationDirective { }
-
@@ -614,10 +604,8 @@ and reference assets of different types.
-
@NgModule({ ... })
export class AppModule
-
@@ -635,10 +623,8 @@ and reference assets of different types.
@@ -1520,10 +1494,8 @@ A consistent class and file name convention make these modules easy to spot and
-
@NgModule({ ... })
export class AppModule { }
-
@@ -1541,10 +1513,8 @@ A consistent class and file name convention make these modules easy to spot and
-
@NgModule({ ... })
export class HeroesModule { }
-
@@ -1562,10 +1532,8 @@ A consistent class and file name convention make these modules easy to spot and
-
@NgModule({ ... })
export class VillainsModule { }
-
@@ -1583,10 +1551,8 @@ A consistent class and file name convention make these modules easy to spot and
-
@NgModule({ ... })
export class AppRoutingModule { }
-
@@ -1604,10 +1570,8 @@ A consistent class and file name convention make these modules easy to spot and
-
@NgModule({ ... })
export class HeroesRoutingModule { }
-
@@ -4667,5 +4631,4 @@ Useful tools and tips for Angular.
Back to top
-
回到顶部
diff --git a/aio/content/guide/template-syntax.md b/aio/content/guide/template-syntax.md
index 4af7c0a80c..741b84cded 100644
--- a/aio/content/guide/template-syntax.md
+++ b/aio/content/guide/template-syntax.md
@@ -75,7 +75,6 @@ You met the double-curly braces of interpolation, `{{` and `}}`, early in your A
在以前的 Angular 教程中,你遇到过由双花括号括起来的插值表达式,`{{` 和 `}}`。
-
You use interpolation to weave calculated strings into the text between HTML element tags and within attribute assignments.
@@ -83,7 +82,6 @@ You use interpolation to weave calculated strings into the text between HTML ele
插值表达式可以把计算后的字符串插入到 HTML 元素标签内的文本或对标签的属性进行赋值。
-
The text between the braces is often the name of a component property. Angular replaces that name with the
@@ -101,7 +99,6 @@ and then **converts to a string**. The following interpolation illustrates the p
下列插值表达式通过把括号中的两个数字相加说明了这一点:
-
The expression can invoke methods of the host component such as `getVal()`, seen here:
@@ -109,7 +106,6 @@ The expression can invoke methods of the host component such as `getVal()`, seen
这个表达式可以调用宿主组件的方法,就像下面用的 `getVal()`:
-
Angular evaluates all expressions in double curly braces,
@@ -178,7 +174,7 @@ JavaScript 中那些具有或可能引发副作用的表达式是被禁止的,
* increment and decrement operators (`++` and `--`)
- 自增或自减操作符 (`++` 和 `--`)
+ 自增和自减运算符:`++` 和 `--`
Other notable differences from JavaScript syntax include:
@@ -206,7 +202,6 @@ In the following snippets, the `title` within double-curly braces and the
在下面的代码片段中,双花括号中的 `title` 和引号中的 `isUnchanged` 所引用的都是 `AppComponent` 中的属性。
-
An expression may also refer to properties of the _template's_ context
@@ -217,7 +212,6 @@ or a [template reference variable](guide/template-syntax#ref-vars) (`#heroInput`
比如[模板输入变量](guide/template-syntax#template-input-variable) (`let hero`)和[模板引用变量](guide/template-syntax#ref-vars)(`#heroInput`)就是备选的上下文对象之一。
-
The context for terms in an expression is a blend of the _template variables_,
@@ -368,7 +362,6 @@ appearing in quotes to the right of the `=` symbol as in `(event)="statemen
模板语句将在[事件绑定](guide/template-syntax#event-binding)一节看到,它出现在 `=` 号右侧的引号中,就像这样:`(event)="statement"`。
-
A template statement *has a side effect*.
@@ -432,7 +425,6 @@ The *deleteHero* in `(click)="deleteHero()"` is a method of the data-bound compo
`(click)="deleteHero()"` 中的 *deleteHero* 就是这个数据绑定组件上的一个方法。
-
The statement context may also refer to properties of the template's own context.
@@ -445,7 +437,6 @@ are passed to an event handling method of the component.
在下面的例子中,就把模板的 `$event` 对象、[模板输入变量](guide/template-syntax#template-input-variable) (`let hero`)和[模板引用变量](guide/template-syntax#ref-vars) (`#heroForm`)传给了组件中的一个事件处理器方法。
-
Template context names take precedence over component context names.
@@ -518,7 +509,6 @@ from the _source-to-view_, from _view-to-source_, and in the two-way sequence: _
-
@@ -546,7 +536,6 @@ from the _source-to-view_, from _view-to-source_, and in the two-way sequence: _
-
@@ -560,11 +549,9 @@ from the _source-to-view_, from _view-to-source_, and in the two-way sequence: _
@@ -646,9 +628,7 @@ from the _source-to-view_, from _view-to-source_, and in the two-way sequence: _
-
-
@@ -704,7 +684,6 @@ you modify those elements by setting element attributes with string constants.
通过把字符串常量设置到元素的 attribute 来修改那些元素。
-
You still create a structure and initialize attribute values this way in Angular templates.
@@ -717,7 +696,6 @@ and drop them into templates as if they were native HTML elements.
然后,用封装了 HTML 的组件创建新元素,并把它们当作原生 HTML 元素在模板中使用。
-
That's HTML Plus.
@@ -729,7 +707,6 @@ Then you learn about data binding. The first binding you meet might look like th
现在开始学习数据绑定。你碰到的第一种数据绑定是这样的:
-
You'll get to that peculiar bracket notation in a moment. Looking beyond it,
@@ -880,7 +857,6 @@ The following table summarizes:
-
@@ -908,7 +884,6 @@ The following table summarizes:
-
@@ -934,13 +909,11 @@ The following table summarizes:
-
-
@@ -966,13 +939,11 @@ The following table summarizes:
-
-
@@ -994,13 +965,11 @@ The following table summarizes:
-
-
@@ -1021,13 +990,11 @@ The following table summarizes:
-
-
@@ -1047,13 +1014,11 @@ The following table summarizes:
-
-
@@ -1073,13 +1038,11 @@ The following table summarizes:
-
-
With this broad view in mind, you're ready to look at binding types in detail.
@@ -1106,7 +1069,6 @@ binding the `src` property of an image element to a component's `heroImageUrl` p
下面这个例子中,image 元素的 `src` 属性会被绑定到组件的 `heroImageUrl` 属性上:
-
Another example is disabling a button when the component says that it `isUnchanged`:
@@ -1114,7 +1076,6 @@ Another example is disabling a button when the component says that it `isUnchang
另一个例子是当组件说它 `isUnchanged`(未改变)时禁用按钮:
-
Another is setting a property of a directive:
@@ -1122,7 +1083,6 @@ Another is setting a property of a directive:
另一个例子是设置指令的属性:
-
Yet another is setting the model property of a custom component (a great way
@@ -1131,7 +1091,6 @@ for parent and child components to communicate):
还有另一个例子是设置自定义组件的模型属性(这是父子组件之间通讯的重要途径):
-
### One-way *in*
@@ -1181,7 +1140,6 @@ The target property in the following code is the image element's `src` property.
包裹在方括号中的元素属性名标记着目标属性。下列代码中的目标属性是 image 元素的 `src` 属性。
-
Some people prefer the `bind-` prefix alternative, known as the *canonical form*:
@@ -1189,7 +1147,6 @@ Some people prefer the `bind-` prefix alternative, known as the *canonical form*
有些人喜欢用 `bind-` 前缀的可选形式,并称之为*规范形式*:
-
The target name is always the name of a property, even when it appears to be the name of something else.
@@ -1205,7 +1162,6 @@ as it is in the following example:
元素属性可能是最常见的绑定目标,但 Angular 会先去看这个名字是否是某个已知指令的属性名,就像下面的例子中一样:
-
@@ -1269,7 +1225,6 @@ The `hero` property of the `HeroDetail` component expects a `Hero` object, which
`HeroDetail` 组件的 `hero` 属性想要一个 `Hero` 对象,那就在属性绑定中精确地给它一个 `Hero` 对象:
-
### Remember the brackets
@@ -1290,7 +1245,6 @@ Don't make the following mistake:
不要出现这样的失误:
-
{@a one-time-initialization}
@@ -1324,7 +1278,6 @@ not a template expression. Angular sets it and forgets about it.
下面这个例子把 `HeroDetailComponent` 的 `prefix` 属性初始化为固定的字符串,而不是模板表达式。Angular 设置它,然后忘记它。
-
The `[hero]` binding, on the other hand, remains a live binding to the component's `currentHero` property.
@@ -1344,7 +1297,6 @@ The following binding pairs do the same thing:
下列这几对绑定做的事情完全相同:
-
_Interpolation_ is a convenient alternative to _property binding_ in many cases.
@@ -1375,7 +1327,6 @@ Imagine the following *malicious content*.
假设下面的*恶意内容*
-
Fortunately, Angular data binding is on alert for dangerous HTML.
@@ -1388,7 +1339,6 @@ nor property binding.
不管是插值表达式还是属性绑定,都**不会**允许带有 script 标签的 HTML 泄漏到浏览器中。
-
Interpolation handles the script tags differently than property binding but both approaches render the
@@ -1453,9 +1403,7 @@ This fact becomes painfully obvious when you write something like this.
如果想写出类似下面这样的东西,就会暴露出痛点了:
-
<tr><td colspan="{{1 + 1}}">Three-Four</td></tr>
-
And you get this error:
@@ -1463,10 +1411,8 @@ And you get this error:
会得到这个错误:
-
Template parse errors:
Can't bind to 'colspan' since it isn't a known native property
-
As the message says, the `
` element does not have a `colspan` property.
@@ -1494,7 +1440,6 @@ Bind `[attr.colspan]` to a calculated value:
这里把 `[attr.colspan]` 绑定到一个计算值:
-
Here's how the table renders:
@@ -1517,16 +1462,10 @@ Here's how the table renders:
- Five
+ Five
Six
-
-
- Six
-
-
-
@@ -1538,7 +1477,6 @@ attribute 绑定的主要用例之一是设置 ARIA attribute(译注:ARIA
就像这个例子中一样:
-
@@ -1566,7 +1504,6 @@ with class bindings. Here's how to set the attribute without binding:
下列例子示范了如何通过 CSS 类绑定来添加和移除应用的 "special" 类。不用绑定直接设置 attribute 时是这样的:
-
You can replace that with a binding to a string of the desired class names; this is an all-or-nothing, replacement binding.
@@ -1575,7 +1512,6 @@ You can replace that with a binding to a string of the desired class names; this
(译注:即当 badCurly 有值时 class 这个 attribute 设置的内容会被完全覆盖)
-
Finally, you can bind to a specific class name.
@@ -1586,7 +1522,6 @@ It removes the class when the expression is falsy.
当模板表达式的求值结果是真值时,Angular 会添加这个类,反之则移除它。
-
@@ -1617,7 +1552,6 @@ followed by a dot (`.`) and the name of a CSS style property: `[style.style-prop
形如:`[style.style-property]`。
-
Some style binding styles have a unit extension.
@@ -1626,7 +1560,6 @@ The following example conditionally sets the font size in “em” and “%”
有些样式绑定中的样式带有单位。在这里,以根据条件用 “em” 和 “%” 来设置字体大小的单位。
-
@@ -1685,7 +1618,6 @@ the component's `onSave()` method whenever a click occurs:
下面事件绑定监听按钮的点击事件。每当点击发生时,都会调用组件的 `onSave()` 方法。
-
### Target event
@@ -1698,7 +1630,6 @@ identifies the target event. In the following example, the target is the button'
**圆括号中的名称** —— 比如 `(click)` —— 标记出目标事件。在下面例子中,目标是按钮的 click 事件。
-
Some people prefer the `on-` prefix alternative, known as the **canonical form**:
@@ -1706,7 +1637,6 @@ Some people prefer the `on-` prefix alternative, known as the **canonical form**
有些人更喜欢带 `on-` 前缀的备选形式,称之为**规范形式**:
-
Element events may be the more common targets, but Angular looks first to see if the name matches an event property
@@ -1715,7 +1645,6 @@ of a known directive, as it does in the following example:
元素事件可能是更常见的目标,但 Angular 会先看这个名字是否能匹配上已知指令的事件属性,就像下面这个例子:
-
@@ -1766,7 +1695,6 @@ Consider this example:
考虑这个范例:
-
This code sets the input box `value` property by binding to the `name` property.
@@ -1818,11 +1746,9 @@ Here are the pertinent excerpts from that `HeroDetailComponent`:
下面的代码节选自 `HeroDetailComponent`:
-
-
The component defines a `deleteRequest` property that returns an `EventEmitter`.
@@ -1837,7 +1763,6 @@ Now imagine a hosting parent component that binds to the `HeroDetailComponent`'s
现在,假设有个宿主的父组件,它绑定了 `HeroDetailComponent` 的 `deleteRequest` 事件。
-
When the `deleteRequest` event fires, Angular calls the parent component's `deleteHero` method,
@@ -1908,7 +1833,6 @@ It has a `size` value property and a companion `sizeChange` event:
下面的 `SizerComponent` 符合这个模式。它有 `size` 属性和伴随的 `sizeChange` 事件:
-
The initial `size` is an input value from a property binding.
@@ -1924,7 +1848,6 @@ Here's an example in which the `AppComponent.fontSizePx` is two-way bound to the
下面的例子中,`AppComponent.fontSize` 被双向绑定到 `SizerComponent`:
-
The `AppComponent.fontSizePx` establishes the initial `SizerComponent.size` value.
@@ -1943,7 +1866,6 @@ Angular _desugars_ the `SizerComponent` binding into this:
Angular 将 `SizerComponent` 的绑定分解成这样:
-
The `$event` variable contains the payload of the `SizerComponent.sizeChange` event.
@@ -1990,7 +1912,6 @@ Why create a directive to handle a click when you can write a simple binding suc
如果能用简单的绑定达到目的,为什么还要创建指令来处理点击事件呢?
-
You still benefit from directives that simplify complex tasks.
@@ -2060,7 +1981,6 @@ A [class binding](guide/template-syntax#class-binding) is a good way to add or r
[CSS 类绑定](guide/template-syntax#class-binding) 是添加或删除*单个*类的最佳途径。
-
To add or remove *many* CSS classes at the same time, the `NgClass` directive may be the better choice.
@@ -2080,7 +2000,6 @@ Consider a `setCurrentClasses` component method that sets a component property,
组件方法 `setCurrentClasses` 可以把组件的属性 `currentClasses` 设置为一个对象,它将会根据三个其它组件的状态为 `true` 或 `false` 而添加或移除三个类。
-
Adding an `ngClass` property binding to `currentClasses` sets the element's classes accordingly:
@@ -2088,7 +2007,6 @@ Adding an `ngClass` property binding to `currentClasses` sets the element's clas
把 `NgClass` 属性绑定到 `currentClasses`,根据它来设置此元素的 CSS 类:
-
@@ -2116,7 +2034,6 @@ A [style binding](guide/template-syntax#style-binding) is an easy way to set a *
[样式绑定](guide/template-syntax#style-binding)是设置*单一*样式值的简单方式。
-
To set *many* inline styles at the same time, the `NgStyle` directive may be the better choice.
@@ -2135,7 +2052,6 @@ with an object that defines three styles, based on the state of three other comp
来看看组件的 `setCurrentStyles` 方法,它会根据另外三个属性的状态把组件的 `currentStyles` 属性设置为一个定义了三个样式的对象:
-
Adding an `ngStyle` property binding to `currentStyles` sets the element's styles accordingly:
@@ -2143,7 +2059,6 @@ Adding an `ngStyle` property binding to `currentStyles` sets the element's style
把 `NgStyle` 属性绑定到 `currentStyles`,以据此设置此元素的样式:
-
@@ -2172,7 +2087,6 @@ Two-way data binding with the `NgModel` directive makes that easy. Here's an exa
使用 `NgModel` 指令进行双向数据绑定可以简化这种工作。例子如下:
-
#### _FormsModule_ is required to use _ngModel_
@@ -2192,7 +2106,6 @@ Here's how to import the `FormsModule` to make `[(ngModel)]` available.
导入 `FormsModule` 并让 `[(ngModel)]` 可用的代码如下:
-
#### Inside [(ngModel)]
@@ -2206,7 +2119,6 @@ the `` element's `value` property and `input` event.
回头看看 `name` 绑定,注意,你可以通过分别绑定到 `` 元素的 `value` 属性和 `input` 事件来达到同样的效果。
-
That's cumbersome. Who can remember which element property to set and which element event emits user changes?
@@ -2221,7 +2133,6 @@ That `ngModel` directive hides these onerous details behind its own `ngModel` i
`ngModel` 指令通过自己的输入属性 `ngModel` 和输出属性 `ngModelChange` 隐藏了那些细节。
-
@@ -2270,7 +2181,6 @@ with a single declaration, which it can with the `[(ngModel)]` syntax:
你不用被迫两次引用这个数据属性,Angular 可以捕获该元素的数据属性,并且通过一个简单的声明来设置它,这样它就可以使用 `[(ngModel)]` 语法了。
-
Is `[(ngModel)]` all you need? Is there ever a reason to fall back to its expanded form?
@@ -2288,7 +2198,6 @@ The following contrived example forces the input value to uppercase:
下面这个生造的例子强制输入框的内容变成大写:
-
Here are all variations in action, including the uppercase version:
@@ -2368,7 +2277,6 @@ Bind the directive to a condition expression like `isActive` in this example.
在下面的例子中,该指令绑定到了类似于 `isActive` 这样的条件表达式。
-
@@ -2395,7 +2303,6 @@ You can control the visibility of an element with a
你也可以通过[类绑定](guide/template-syntax#class-binding)或[样式绑定](guide/template-syntax#style-binding)来显示或隐藏一个元素。
-
Hiding an element is quite different from removing an element with `NgIf`.
@@ -2445,7 +2352,6 @@ The `nullHero` will never be displayed.
而 `nullHero` 永远不会显示。
-
@@ -2477,7 +2383,6 @@ Here is an example of `NgForOf` applied to a simple `
`:
下例中,`NgFor` 应用在一个简单的 `
` 上:
-
You can also apply an `NgForOf` to a component element, as in this example:
@@ -2485,7 +2390,6 @@ You can also apply an `NgForOf` to a component element, as in this example:
也可以把 `NgFor` 应用在一个组件元素上,就下例这样:
-
@@ -2552,7 +2456,6 @@ and then passed in a binding to the `hero` property of the `` compo
这里它首先在一个插值表达式中被引用到,然后通过一个绑定把它传给了 `` 组件的 `hero` 属性。
-
Learn more about _template input variables_ in the
@@ -2575,7 +2478,6 @@ The next example captures the `index` in a variable named `i` and displays it wi
下面这个例子把 `index` 捕获到了 `i` 变量中,并且把它显示在英雄名字的前面。
-
@@ -2621,7 +2523,6 @@ In this case, that value is the hero's `id`.
在这里,这个值就是英雄的 `id`。
-
In the microsyntax expression, set `trackBy` to this method.
@@ -2629,7 +2530,6 @@ In the microsyntax expression, set `trackBy` to this method.
在微语法中,把 `trackBy` 设置为该方法。
-
Here is an illustration of the _trackBy_ effect.
@@ -2674,7 +2574,6 @@ Angular 只会把*选中的*元素放进 DOM 中。
`NgSwitch` 实际上包括三个相互协作的指令:`NgSwitch`、`NgSwitchCase` 和 `NgSwitchDefault`,例子如下:
-
@@ -2726,7 +2625,6 @@ For example, you could replace the `` switch case with the follow
比如,你可以把 `` 分支改成这样:
-
@@ -2754,7 +2652,6 @@ The `#phone` declares a `phone` variable on an `` element.
`#phone` 的意思就是声明一个名叫 `phone` 的变量来引用 `` 元素。
-
You can refer to a template reference variable _anywhere_ in the template.
@@ -2765,7 +2662,6 @@ consumed in a `