diff --git a/aio/tools/translator/dict-latest.json b/aio/tools/translator/dict-latest.json
index 3666eafc9b..0757e29052 100644
--- a/aio/tools/translator/dict-latest.json
+++ b/aio/tools/translator/dict-latest.json
@@ -41,12 +41,12 @@
},
{
"original": "_Angular_ is the name for the Angular of today and tomorrow.\n_AngularJS_ is the name for all v1.x versions of Angular.",
- "translation": "*Angular*这个名字专指现在和未来的Angular版本,而*AngularJS*专指Angular的所有v1.x版本。",
+ "translation": "*Angular* 这个名字专指现在和未来的 Angular 版本,而 *AngularJS* 专指 Angular 的所有 v1.x 版本。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "This guide helps you transition from AngularJS to Angular\nby mapping AngularJS syntax to the equivalent Angular syntax.",
- "translation": "本章提供了一个快速的参考指南,指出一些常用的AngularJS语法及其在Angular中的等价物。",
+ "translation": "本章提供了一个快速的参考指南,指出一些常用的 AngularJS 语法及其在 Angular 中的等价物。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -61,7 +61,7 @@
},
{
"original": "Templates are the user-facing part of an Angular application and are written in HTML.\nThe following table lists some of the key AngularJS template features with their equivalent Angular template syntax.",
- "translation": "模板是Angular应用中的门面部分,它是用HTML写的。下表中是一些AngularJS中的关键模板特性及其在Angular中的等价语法。",
+ "translation": "模板是 Angular 应用中的门面部分,它是用 HTML 写的。下表中是一些 AngularJS 中的关键模板特性及其在 Angular 中的等价语法。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -71,12 +71,12 @@
},
{
"original": "In AngularJS, an expression in curly braces denotes one-way binding.\n This binds the value of the element to a property in the controller\n associated with this template.",
- "translation": "在AngularJS中,花括号中的表达式代表单向绑定。\n 它把元素的值绑定到了与模板相关控制器的属性上。",
+ "translation": "在 AngularJS 中,花括号中的表达式代表单向绑定。\n 它把元素的值绑定到了与模板相关控制器的属性上。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "When using the `controller as` syntax,\n the binding is prefixed with the controller alias (`vm` or `$ctrl`) because you\n have to be specific about the source of the binding.",
- "translation": "当使用`controller as`语法时,该绑定需要用控制器的别名(`vm`)为前缀,这是因为我们不得不通过它来指定绑定源。",
+ "translation": "当使用 `controller as` 语法时,该绑定需要用控制器的别名(`vm`)为前缀,这是因为你不得不通过它来指定绑定源。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -86,7 +86,7 @@
},
{
"original": "In Angular, a template expression in curly braces still denotes one-way binding.\n This binds the value of the element to a property of the component.\n The context of the binding is implied and is always the\n associated component, so it needs no reference variable.",
- "translation": "在Angular中,花括号中的模板表达式同样代表单向绑定。\n 它把元素的值绑定到了组件的属性上。\n 它绑定的上下文变量是隐式的,并且总是关联到组件。\n 所以,它不需要一个引用变量。",
+ "translation": "在 Angular 中,花括号中的模板表达式同样代表单向绑定。\n 它把元素的值绑定到了组件的属性上。\n 它绑定的上下文变量是隐式的,并且总是关联到组件。\n 所以,它不需要一个引用变量。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -101,12 +101,12 @@
},
{
"original": "To filter output in AngularJS templates, use the pipe character (|) and one or more filters.",
- "translation": "要在AngularJS中过滤输出,使用管道字符(|)以及一个或多个过滤器。",
+ "translation": "要在 AngularJS 中过滤输出,使用管道字符(|)以及一个或多个过滤器。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "This example filters the `title` property to uppercase.",
- "translation": "这个例子中把`title`属性过滤成了大写形式。",
+ "translation": "这个例子中把 `title` 属性过滤成了大写形式。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -116,7 +116,7 @@
},
{
"original": "In Angular you use similar syntax with the pipe (|) character to filter output, but now you call them **pipes**.\n Many (but not all) of the built-in filters from AngularJS are\n built-in pipes in Angular.",
- "translation": "在Angular中,我们使用相似的语法 —— 用管道字符(|)来过滤输出,但是现在直接把它叫做**管道**了。\n 很多(但不是所有)AngularJS中的内置过滤器也成了Angular中的内置管道。",
+ "translation": "在 Angular 中,你使用类似的语法 —— 用管道字符(|)来过滤输出,但是现在直接把它叫做**管道**了。\n 很多(但不是所有)AngularJS 中的内置过滤器也成了 Angular 中的内置管道。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -131,7 +131,7 @@
},
{
"original": "Here, `movie` is a user-defined local variable.",
- "translation": "这里的`movie`是一个用户定义的局部变量",
+ "translation": "这里的 `movie` 是一个用户定义的局部变量",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -141,12 +141,12 @@
},
{
"original": "Angular has true template input variables that are explicitly defined using the `let` keyword.",
- "translation": "Angular 有了真正的模板输入变量,它需要使用`let`关键字进行明确定义。",
+ "translation": "Angular 有了真正的模板输入变量,它需要使用 `let` 关键字进行明确定义。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "For more information, see the [ngFor micro-syntax](guide/template-syntax#microsyntax)\n section of the [Template Syntax](guide/template-syntax) page.",
- "translation": "要了解更多信息,请参见[模板语法](guide/template-syntax)中的[ngFor微语法](guide/template-syntax#microsyntax)部分。",
+ "translation": "要了解更多信息,请参见[模板语法](guide/template-syntax)中的[ngFor 微语法](guide/template-syntax#microsyntax)部分。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -156,7 +156,7 @@
},
{
"original": "AngularJS provides more than seventy built-in directives for templates.\nMany of them aren't needed in Angular because of its more capable and expressive binding system.\nThe following are some of the key AngularJS built-in directives and their equivalents in Angular.",
- "translation": "AngularJS 为模板提供了七十多个内置指令。\n在 Angular 中,它们很多都已经不需要了,因为 Angular 有了一个更加强大、快捷的绑定系统。\n下面是一些AngularJS 中的关键指令及其在 Angular 中的等价物。",
+ "translation": "AngularJS 为模板提供了七十多个内置指令。\n在 Angular 中,它们很多都已经不需要了,因为 Angular 有了一个更加强大、快捷的绑定系统。\n下面是一些 AngularJS 中的关键指令及其在 Angular 中的等价物。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -166,7 +166,7 @@
},
{
"original": "Although you can bootstrap an AngularJS app in code,\n many applications bootstrap declaratively with the `ng-app` directive,\n giving it the name of the application's module (`movieHunter`).",
- "translation": "虽然可以从代码中引导Angular应用,\n 但很多应用都是通过`ng-app`指令进行声明式引导的,只要给它一个应用模块的名字(`movieHunter`)就可以了。",
+ "translation": "虽然可以从代码中引导 Angular 应用,\n 但很多应用都是通过 `ng-app` 指令进行声明式引导的,只要给它一个应用模块的名字(`movieHunter`)就可以了。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -176,17 +176,17 @@
},
{
"original": "Angular doesn't have a bootstrap directive.\n To launch the app in code, explicitly bootstrap the application's root module (`AppModule`)\n in `main.ts`\n and the application's root component (`AppComponent`) in `app.module.ts`.",
- "translation": "Angular 没有引导指令。\n 总是要通过显式调用一个`bootstrap`函数,并传入应用模块的名字(`AppComponent`)来启动应用。",
+ "translation": "Angular 没有引导指令。\n 总是要通过显式调用一个 `bootstrap` 函数,并传入应用模块的名字(`AppComponent`)来启动应用。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In AngularJS, the `ng-class` directive includes/excludes CSS classes\n based on an expression. That expression is often a key-value control object with each\n key of the object defined as a CSS class name, and each value defined as a template expression\n that evaluates to a Boolean value.",
- "translation": "在AngularJS中,`ng-class`指令会基于一个表达式来包含/排除某些CSS类。该表达式通常是一个“键-值”型的控制对象,\n 对象中的每一个键代表一个CSS类名,每一个值定义为一个返回布尔值的模板表达式。",
+ "translation": "在 AngularJS 中,`ng-class` 指令会基于一个表达式来包含/排除某些 CSS 类。该表达式通常是一个“键-值”型的控制对象,\n 对象中的每一个键代表一个 CSS 类名,每一个值定义为一个返回布尔值的模板表达式。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In the first example, the `active` class is applied to the element if `isActive` is true.",
- "translation": "在第一个例子中,如果`isActive`为真,则`active`类被应用到那个元素上。",
+ "translation": "在第一个例子中,如果 `isActive` 为真,则 `active` 类被应用到那个元素上。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -196,12 +196,12 @@
},
{
"original": "In Angular, the `ngClass` directive works similarly.\n It includes/excludes CSS classes based on an expression.",
- "translation": "在Angular中,`ngClass`指令用类似的方式工作。\n 它根据一个表达式包含/排除某些CSS类。",
+ "translation": "在 Angular 中,`ngClass` 指令用类似的方式工作。\n 它根据一个表达式包含/排除某些 CSS 类。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In the first example, the `active` class is applied to the element if `isActive` is true.",
- "translation": "在第一个例子中,如果`isActive`为真,则`active`类被应用到那个元素上。",
+ "translation": "在第一个例子中,如果 `isActive` 为真,则 `active` 类被应用到那个元素上。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -211,57 +211,57 @@
},
{
"original": "Angular also has **class binding**, which is a good way to add or remove a single class,\n as shown in the third example.",
- "translation": "Angular还有**类绑定**,它是单独添加或移除一个类的好办法 —— 就像第三个例子中展示的。",
+ "translation": "Angular 还有**类绑定**,它是单独添加或移除一个类的好办法 —— 就像第三个例子中展示的。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "For more information see the [Attribute, class, and style bindings](guide/template-syntax#other-bindings)\n section of the [Template Syntax](guide/template-syntax) page.",
- "translation": "要了解更多信息,参见[模板语法](guide/template-syntax)中的[属性、CSS类和样式绑定](guide/template-syntax#other-bindings)部分。",
+ "translation": "要了解更多信息,参见[模板语法](guide/template-syntax)中的[属性、CSS 类和样式绑定](guide/template-syntax#other-bindings)部分。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In AngularJS, the `ng-click` directive allows you to specify custom behavior when an element is clicked.",
- "translation": "在AngularJS中,`ng-click`指令指定当元素被点击时的自定义行为。",
+ "translation": "在 AngularJS 中,`ng-click` 指令指定当元素被点击时的自定义行为。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In the first example, when the user clicks the button, the `toggleImage()` method in the controller referenced by the `vm` `controller as` alias is executed.",
- "translation": "在第一个例子中,如果用户点击了这个按钮,那么控制器的`toggleImage()`方法就会被执行,这个控制器是被`controller as`中指定的`vm`别名所引用的。",
+ "translation": "在第一个例子中,如果用户点击了这个按钮,那么控制器的 `toggleImage()` 方法就会被执行,这个控制器是被 `controller as` 中指定的 `vm` 别名所引用的。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "The second example demonstrates passing in the `$event` object, which provides details about the event\n to the controller.",
- "translation": "第二个例子演示了传入`$event`对象,它提供了事件的详情,并被传到控制器。",
+ "translation": "第二个例子演示了传入 `$event` 对象,它提供了事件的详情,并被传到控制器。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "### Bind to the `click` event",
- "translation": "### 绑定到`click`事件",
+ "translation": "### 绑定到 `click` 事件",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "AngularJS event-based directives do not exist in Angular.\n Rather, define one-way binding from the template view to the component using **event binding**.",
- "translation": "AngularJS基于事件的指令在Angular中已经不存在了。\n 不过,可以使用**事件绑定**来定义从模板视图到组件的单向数据绑定。",
+ "translation": "AngularJS 基于事件的指令在 Angular 中已经不存在了。\n 不过,可以使用**事件绑定**来定义从模板视图到组件的单向数据绑定。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "For event binding, define the name of the target event within parenthesis and\n specify a template statement, in quotes, to the right of the equals. Angular then\n sets up an event handler for the target event. When the event is raised, the handler\n executes the template statement.",
- "translation": "要使用事件绑定,把目标事件的名字放在圆括号中,并且使用等号右侧引号中的模板语句对它赋值。\n 然后Angular为这个目标时间设置事件处理器。当事件被触发时,这个处理器就会执行模板语句。",
+ "translation": "要使用事件绑定,把目标事件的名字放在圆括号中,并且使用等号右侧引号中的模板语句对它赋值。\n 然后 Angular 为这个目标时间设置事件处理器。当事件被触发时,这个处理器就会执行模板语句。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In the first example, when a user clicks the button, the `toggleImage()` method in the associated component is executed.",
- "translation": "在第一个例子中,当用户点击此按钮时,相关组件中的`toggleImage()`方法就被执行了。",
+ "translation": "在第一个例子中,当用户点击此按钮时,相关组件中的 `toggleImage()` 方法就被执行了。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "The second example demonstrates passing in the `$event` object, which provides details about the event\n to the component.",
- "translation": "第二个例子演示了如何传入`$event`对象,它为组件提供了此事件的详情。",
+ "translation": "第二个例子演示了如何传入 `$event` 对象,它为组件提供了此事件的详情。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "For a list of DOM events, see: https://developer.mozilla.org/en-US/docs/Web/Events.",
- "translation": "要查看DOM事件的列表,请参见[网络事件](https://developer.mozilla.org/en-US/docs/Web/Events)。",
+ "translation": "要查看 DOM 事件的列表,请参见[网络事件](https://developer.mozilla.org/en-US/docs/Web/Events)。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -271,7 +271,7 @@
},
{
"original": "In AngularJS, the `ng-controller` directive attaches a controller to the view.\n Using the `ng-controller` (or defining the controller as part of the routing) ties the\n view to the controller code associated with that view.",
- "translation": "在AngularJS中,`ng-controller`指令把控制器附加到视图上。\n 使用`ng-controller`(或把控制器定义为路由的一部分)把视图及其控制器的代码联系在一起。",
+ "translation": "在 AngularJS 中,`ng-controller` 指令把控制器附加到视图上。\n 使用 `ng-controller`(或把控制器定义为路由的一部分)把视图及其控制器的代码联系在一起。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -281,7 +281,7 @@
},
{
"original": "In Angular, the template no longer specifies its associated controller.\n Rather, the component specifies its associated template as part of the component class decorator.",
- "translation": "在Angular中,模板不用再指定它相关的控制器。\n 反过来,组件会在组件类的装饰器中指定与它相关的模板。",
+ "translation": "在 Angular 中,模板不用再指定它相关的控制器。\n 反过来,组件会在组件类的装饰器中指定与它相关的模板。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -291,42 +291,42 @@
},
{
"original": "In AngularJS, the `ng-hide` directive shows or hides the associated HTML element based on\n an expression. For more information, see [ng-show](guide/ajs-quick-reference#ng-show).",
- "translation": "在AngularJS中,`ng-hide`指令会基于一个表达式显示或隐藏相关的HTML元素。\n 参见[ng-show](guide/ajs-quick-reference#ng-show)了解更多。",
+ "translation": "在 AngularJS 中,`ng-hide` 指令会基于一个表达式显示或隐藏相关的 HTML 元素。\n 参见[ng-show](guide/ajs-quick-reference#ng-show)了解更多。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "### Bind to the `hidden` property",
- "translation": "### 绑定到`hidden`属性",
+ "translation": "### 绑定到 `hidden` 属性",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In Angular, you use property binding; there is no built-in *hide* directive.\n For more information, see [ng-show](guide/ajs-quick-reference#ng-show).",
- "translation": "在Angular中,并没有一个内置的*hide*指令,可以改用属性绑定。\n 参见[ng-show](guide/ajs-quick-reference#ng-show)了解更多。",
+ "translation": "在 Angular 中,并没有一个内置的 *hide* 指令,可以改用属性绑定。\n 参见[ng-show](guide/ajs-quick-reference#ng-show)了解更多。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "The `ng-href` directive allows AngularJS to preprocess the `href` property so that it\n can replace the binding expression with the appropriate URL before the browser\n fetches from that URL.",
- "translation": "`ng-href`指令允许AngularJS对`href`属性进行预处理,以便它能在浏览器获取那个URL之前,使用一个返回适当URL的绑定表达式替换它。",
+ "translation": "`ng-href` 指令允许 AngularJS 对 `href` 属性进行预处理,以便它能在浏览器获取那个 URL 之前,使用一个返回适当 URL 的绑定表达式替换它。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In AngularJS, the `ng-href` is often used to activate a route as part of navigation.",
- "translation": "在AngularJS 中,`ng-href`通常用来作为导航的一部分,激活一个路由。",
+ "translation": "在 AngularJS 中,`ng-href` 通常用来作为导航的一部分,激活一个路由。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "Routing is handled differently in Angular.",
- "translation": "路由在Angular中的处理方式不同。",
+ "translation": "路由在 Angular 中的处理方式不同。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "### Bind to the `href` property",
- "translation": "### 绑定到`href`属性",
+ "translation": "### 绑定到 `href` 属性",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "Angular uses property binding; there is no built-in *href* directive.\n Place the element's `href` property in square brackets and set it to a quoted template expression.",
- "translation": "在Angular中,并没有内置的*href*指令,改用属性绑定。\n 我们把元素的`href`属性放在方括号中,并把它设成一个引号中的模板表达式。",
+ "translation": "在 Angular 中,并没有内置的 *href* 指令,改用属性绑定。\n 把元素的 `href` 属性放在方括号中,并把它设成一个引号中的模板表达式。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -336,72 +336,72 @@
},
{
"original": "In Angular, `href` is no longer used for routing. Routing uses `routerLink`, as shown in the following example.",
- "translation": "在Angular中,`href`不再用作路由,而是改用第三个例子中所展示的`routerLink`指令。",
+ "translation": "在 Angular 中,`href` 不再用作路由,而是改用第三个例子中所展示的 `routerLink` 指令。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "For more information on routing, see the [RouterLink binding](guide/router#router-link)\n section of the [Routing & Navigation](guide/router) page.",
- "translation": "要了解关于路由的更多信息,请参见[路由与导航](guide/router)的[RouterLink绑定](guide/router#router-link)部分。",
+ "translation": "要了解关于路由的更多信息,请参见[路由与导航](guide/router)的[RouterLink 绑定](guide/router#router-link)部分。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In AngularJS, the `ng-if` directive removes or recreates a portion of the DOM,\n based on an expression. If the expression is false, the element is removed from the DOM.",
- "translation": "在AngularJS中,`ng-if`指令会根据一个表达式来移除或重建DOM中的一部分。如果表达式为假,元素就会被从DOM中移除。",
+ "translation": "在 AngularJS 中,`ng-if` 指令会根据一个表达式来移除或重建 DOM 中的一部分。如果表达式为假,元素就会被从 DOM 中移除。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In this example, the `
` element is removed from the DOM unless the `movies` array has a length greater than zero.",
- "translation": "在这个例子中,除非`movies`数组的长度大于0,否则`
` 元素就会被从 DOM 中移除。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "The `*ngIf` directive in Angular works the same as the `ng-if` directive in AngularJS. It removes\n or recreates a portion of the DOM based on an expression.",
- "translation": "Angular中的`*ngIf`指令与AngularJS中的`ng-if`指令一样,\n 它根据表达式的值移除或重建DOM中的一部分。",
+ "translation": "Angular 中的 `*ngIf` 指令与 AngularJS 中的 `ng-if` 指令一样,\n 它根据表达式的值移除或重建 DOM 中的一部分。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In this example, the `
` element is removed from the DOM unless the `movies` array has a length.",
- "translation": "在这个例子中,除非`movies`数组的长度大于0,否则`
` 元素就会被从 DOM 中移除。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "The (*) before `ngIf` is required in this example.\n For more information, see [Structural Directives](guide/structural-directives).",
- "translation": "在这个例子中`ngIf`前的星号(*)是必须的。\n 要了解更多信息,参见[结构型指令](guide/structural-directives)。",
+ "translation": "在这个例子中 `ngIf` 前的星号(*)是必须的。\n 要了解更多信息,参见[结构型指令](guide/structural-directives)。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In AngularJS, the `ng-model` directive binds a form control to a property in the controller associated with the template.\n This provides **two-way binding**, whereby any change made to the value in the view is synchronized with the model, and any change to the model is synchronized with the value in the view.",
- "translation": "在Angular1中,`ng-model`指令把一个表单控件绑定到了模板相关控制器的一个属性上。\n 这提供了**双向绑定**功能,因此,任何对视图中值的改动,都会同步到模型中,对模型的改动,也会同步到视图中。",
+ "translation": "在 Angular1 中,`ng-model` 指令把一个表单控件绑定到了模板相关控制器的一个属性上。\n 这提供了**双向绑定**功能,因此,任何对视图中值的改动,都会同步到模型中,对模型的改动,也会同步到视图中。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In Angular, **two-way binding** is denoted by `[()]`, descriptively referred to as a \"banana in a box\". This syntax is a shortcut for defining both property binding (from the component to the view)\n and event binding (from the view to the component), thereby providing two-way binding.",
- "translation": "在Angular中,**双向绑定**使用[()]标记出来,它被形象的比作“盒子中的香蕉”。\n 这种语法是一个简写形式,用来同时定义一个属性绑定(从组件到视图)和一个事件绑定(从视图到组件),因此,我们得到了双向绑定。",
+ "translation": "在 Angular 中,**双向绑定**使用[()]标记出来,它被形象的比作“盒子中的香蕉”。\n 这种语法是一个简写形式,用来同时定义一个属性绑定(从组件到视图)和一个事件绑定(从视图到组件),就成了双向绑定。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "For more information on two-way binding with `ngModel`, see the [NgModel—Two-way binding to\n form elements with `[(ngModel)]`](../guide/template-syntax.html#ngModel)\n section of the [Template Syntax](guide/template-syntax) page.",
- "translation": "要了解使用ngModel进行双向绑定的更多知识,参见[模板语法](guide/template-syntax)中的[NgModel—使用`[(ngModel)]`进行双向绑定](../guide/template-syntax.html#ngModel)部分。",
+ "translation": "要了解使用 ngModel 进行双向绑定的更多知识,参见[模板语法](guide/template-syntax)中的[NgModel—使用 `[(ngModel)]` 进行双向绑定](../guide/template-syntax.html#ngModel)部分。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In AngularJS, the `ng-repeat` directive repeats the associated DOM element\n for each item in the specified collection.",
- "translation": "在Angular1中,`ng-repeat`指令会为指定集合中的每一个条目重复渲染相关的DOM元素。",
+ "translation": "在 Angular1 中,`ng-repeat` 指令会为指定集合中的每一个条目重复渲染相关的 DOM 元素。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In this example, the table row (`
`) element repeats for each movie object in the collection of movies.",
- "translation": "在这个例子中,对`movies`集合中的每一个`movie`对象重复渲染了这个表格行元素(`
`)。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "The `*ngFor` directive in Angular is similar to the `ng-repeat` directive in AngularJS. It repeats\n the associated DOM element for each item in the specified collection.\n More accurately, it turns the defined element (`
` in this example) and its contents into a template and\n uses that template to instantiate a view for each item in the list.",
- "translation": "Angular中的`*ngFor`指令类似于AngularJS中的`ng-repeat`指令。\n 它为指定集合中的每一个条目重复渲染了相关的DOM元素。\n 更准确的说,它把被界定出来的元素(这个例子中是`
`)及其内容转成了一个模板,并使用那个模板来为列表中的每一个条目实例化一个视图。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "Notice the other syntax differences:\n The (*) before `ngFor` is required;\n the `let` keyword identifies `movie` as an input variable;\n the list preposition is `of`, not `in`.",
- "translation": "请注意其它语法上的差异:\n 在`ngFor`前面的星号(*)是必须的;`let`关键字把`movie`标记成一个输入变量;列表中使用的介词是`of`,而不再是`in`。",
+ "translation": "请注意其它语法上的差异:\n 在 `ngFor` 前面的星号(*)是必须的;`let` 关键字把 `movie` 标记成一个输入变量;列表中使用的介词是 `of`,而不再是 `in`。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -411,32 +411,32 @@
},
{
"original": "In AngularJS, the `ng-show` directive shows or hides the associated DOM element, based on\n an expression.",
- "translation": "在AngularJS中,`ng-show`指令根据一个表达式来显示或隐藏相关的DOM元素。",
+ "translation": "在 AngularJS 中,`ng-show` 指令根据一个表达式来显示或隐藏相关的 DOM 元素。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In this example, the `
` element is shown if the `favoriteHero` variable is truthy.",
- "translation": "在这个例子中,如果`favoriteHero`变量为真,`
` 元素就会显示出来。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "### Bind to the `hidden` property",
- "translation": "### 绑定到`hidden`属性",
+ "translation": "### 绑定到 `hidden` 属性",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "Angular uses property binding; there is no built-in *show* directive.\n For hiding and showing elements, bind to the HTML `hidden` property.",
- "translation": "在Angular中,并没有内置的*show*指令,可以改用属性绑定。\n 要隐藏或显示一个元素,绑定到它的`hidden`属性就可以了。",
+ "translation": "在 Angular 中,并没有内置的 *show* 指令,可以改用属性绑定。\n 要隐藏或显示一个元素,绑定到它的 `hidden` 属性就可以了。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "To conditionally display an element, place the element's `hidden` property in square brackets and\n set it to a quoted template expression that evaluates to the *opposite* of *show*.",
- "translation": "要想有条件的显示一个元素,就把该元素的`hidden`属性放到一个方括号里,并且把它设置为引号中的模板表达式,它的结果应该是与*显示*时*相反*的值。",
+ "translation": "要想有条件的显示一个元素,就把该元素的 `hidden` 属性放到一个方括号里,并且把它设置为引号中的模板表达式,它的结果应该是与*显示*时*相反*的值。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In this example, the `
` element is hidden if the `favoriteHero` variable is not truthy.",
- "translation": "在这个例子中,如果`favoriteHero`变量不是真值,`
` 元素就会被隐藏。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -446,17 +446,17 @@
},
{
"original": "The `ng-src` directive allows AngularJS to preprocess the `src` property so that it\n can replace the binding expression with the appropriate URL before the browser\n fetches from that URL.",
- "translation": "`ng-src`指令允许AngularJS对`src`属性进行预处理,以便它能够在浏览器获取此URL之前,用一个返回适当URL的绑定表达式替换它。",
+ "translation": "`ng-src` 指令允许 AngularJS 对 `src` 属性进行预处理,以便它能够在浏览器获取此 URL 之前,用一个返回适当 URL 的绑定表达式替换它。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "### Bind to the `src` property",
- "translation": "### 绑定到`src`属性",
+ "translation": "### 绑定到 `src` 属性",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "Angular uses property binding; there is no built-in *src* directive.\n Place the `src` property in square brackets and set it to a quoted template expression.",
- "translation": "在Angular中,并没有一个内置的*src*指令,可以使用属性绑定。\n 把`src`属性放到方括号中,并且把它设为一个引号中的绑定表达式。",
+ "translation": "在 Angular 中,并没有一个内置的 *src* 指令,可以使用属性绑定。\n 把 `src` 属性放到方括号中,并且把它设为一个引号中的绑定表达式。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -466,27 +466,27 @@
},
{
"original": "In AngularJS, the `ng-style` directive sets a CSS style on an HTML element\n based on an expression. That expression is often a key-value control object with each\n key of the object defined as a CSS property, and each value defined as an expression\n that evaluates to a value appropriate for the style.",
- "translation": "在AngularJS中,`ng-style`指令根据一个绑定表达式设置一个HTML元素的CSS样式。\n 该表达式通常是一个“键-值”形式的控制对象,对象的每个键都是一个CSS属性,每个值都是一个能计算为此样式的合适值的表达式。",
+ "translation": "在 AngularJS 中,`ng-style` 指令根据一个绑定表达式设置一个 HTML 元素的 CSS 样式。\n 该表达式通常是一个“键-值”形式的控制对象,对象的每个键都是一个 CSS 属性,每个值都是一个能计算为此样式的合适值的表达式。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In the example, the `color` style is set to the current value of the `colorPreference` variable.",
- "translation": "在这个例子中,`color`样式被设置为`colorPreference`变量的当前值。",
+ "translation": "在这个例子中,`color` 样式被设置为 `colorPreference` 变量的当前值。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In Angular, the `ngStyle` directive works similarly. It sets a CSS style on an HTML element based on an expression.",
- "translation": "在Angular中,`ngStyle`指令的工作方式与此类似。它根据一个表达式设置HTML元素上的CSS样式。",
+ "translation": "在 Angular 中,`ngStyle` 指令的工作方式与此类似。它根据一个表达式设置 HTML 元素上的 CSS 样式。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In the first example, the `color` style is set to the current value of the `colorPreference` variable.",
- "translation": "在第一个例子中,`color`样式被设置成了`colorPreference`变量的当前值。",
+ "translation": "在第一个例子中,`color` 样式被设置成了 `colorPreference` 变量的当前值。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "Angular also has **style binding**, which is good way to set a single style. This is shown in the second example.",
- "translation": "Angular还有**样式绑定**语法,它是单独设置一个样式的好方法。它展示在第二个例子中。",
+ "translation": "Angular 还有**样式绑定**语法,它是单独设置一个样式的好方法。它展示在第二个例子中。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -496,37 +496,37 @@
},
{
"original": "For more information on the `ngStyle` directive, see [NgStyle](guide/template-syntax#ngStyle)\n section of the [Template Syntax](guide/template-syntax) page.",
- "translation": "要了解关于`ngStyle`指令的更多知识,参见[模板语法](guide/template-syntax)中的[NgStyle](guide/template-syntax#ngStyle)部分。",
+ "translation": "要了解关于 `ngStyle` 指令的更多知识,参见[模板语法](guide/template-syntax)中的[NgStyle](guide/template-syntax#ngStyle)部分。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In AngularJS, the `ng-switch` directive swaps the contents of\n an element by selecting one of the templates based on the current value of an expression.",
- "translation": "在Angular1中,`ng-switch`指令根据一个表达式的当前值把元素的内容替换成几个模板之一。",
+ "translation": "在 Angular1 中,`ng-switch` 指令根据一个表达式的当前值把元素的内容替换成几个模板之一。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In this example, if `favoriteHero` is not set, the template displays \"Please enter ...\".\n If `favoriteHero` is set, it checks the movie hero by calling a controller method.\n If that method returns `true`, the template displays \"Excellent choice!\".\n If that methods returns `false`, the template displays \"No movie, sorry!\".",
- "translation": "在这个例子中,如果`favoriteHero`没有设置,则模板显示“Please enter ...”。\n 如果`favoriteHero`设置过,它就会通过调用一个控制其方法来检查它是否电影里的英雄。\n 如果该方法返回`true`,模板就会显示“Excellent choice!”。\n 如果该方法返回`false`,该模板就会显示“No movie, sorry!”。",
+ "translation": "在这个例子中,如果 `favoriteHero` 没有设置,则模板显示“Please enter ...”。\n 如果 `favoriteHero` 设置过,它就会通过调用一个控制其方法来检查它是否电影里的英雄。\n 如果该方法返回 `true`,模板就会显示“Excellent choice!”。\n 如果该方法返回 `false`,该模板就会显示“No movie, sorry!”。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In Angular, the `ngSwitch` directive works similarly.\n It displays an element whose `*ngSwitchCase` matches the current `ngSwitch` expression value.",
- "translation": "在Angular中,`ngSwitch`指令的工作方式与此类似。\n 它会显示那个与`ngSwitch`表达式的当前值匹配的那个`*ngSwitchCase`所在的元素。",
+ "translation": "在 Angular 中,`ngSwitch` 指令的工作方式与此类似。\n 它会显示那个与 `ngSwitch` 表达式的当前值匹配的那个 `*ngSwitchCase` 所在的元素。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In this example, if `favoriteHero` is not set, the `ngSwitch` value is `null`\n and `*ngSwitchDefault` displays, \"Please enter ...\".\n If `favoriteHero` is set, the app checks the movie hero by calling a component method.\n If that method returns `true`, the app selects `*ngSwitchCase=\"true\"` and displays: \"Excellent choice!\"\n If that methods returns `false`, the app selects `*ngSwitchCase=\"false\"` and displays: \"No movie, sorry!\"",
- "translation": "在这个例子中,如果`favoriteHero`没有设置,则`ngSwitch`的值是`null`,我们会看到\n `*ngSwitchDefault`中的段落“Please enter ...”。\n 如果`favoriteHero`被设置了,它就会通过调用一个组件方法来检查电影英雄。\n 如果该方法返回`true`,我们就会看到“Excellent choice!”。\n 如果该方法返回`false`,我们就会看到“No movie, sorry!”。",
+ "translation": "在这个例子中,如果 `favoriteHero` 没有设置,则 `ngSwitch` 的值是 `null`,\n `*ngSwitchDefault` 中会显示 “Please enter ...”。\n 如果设置了 `favoriteHero`,应用就会通过调用一个组件方法来检查电影英雄。\n 如果该方法返回 `true`,就会显示 “Excellent choice!”。\n 如果该方法返回 `false`,就会显示 “No movie, sorry!”。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "The (*) before `ngSwitchCase` and `ngSwitchDefault` is required in this example.",
- "translation": "在这个例子中,`ngSwitchCase`和`ngSwitchDefault`前面的星号(*)是必须的。",
+ "translation": "在这个例子中,`ngSwitchCase` 和 `ngSwitchDefault` 前面的星号(*)是必须的。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "For more information, see [The NgSwitch directives](guide/template-syntax#ngSwitch)\n section of the [Template Syntax](guide/template-syntax) page.",
- "translation": "要了解更多信息,参见[模板语法](guide/template-syntax)中的[NgSwitch指令](guide/template-syntax#ngSwitch)部分。",
+ "translation": "要了解更多信息,参见[模板语法](guide/template-syntax)中的[NgSwitch 指令](guide/template-syntax#ngSwitch)部分。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -536,7 +536,7 @@
},
{
"original": "Angular **pipes** provide formatting and transformation for data in the template, similar to AngularJS **filters**.\nMany of the built-in filters in AngularJS have corresponding pipes in Angular.\nFor more information on pipes, see [Pipes](guide/pipes).",
- "translation": "Angular中的**管道**为模板提供了格式化和数据转换功能,类似于AngularJS中的**过滤器**。\nAngularJS中的很多内置过滤器在Angular中都有对应的管道。\n要了解管道的更多信息,参见[Pipes](guide/pipes)。",
+ "translation": "Angular 中的**管道**为模板提供了格式化和数据转换功能,类似于 AngularJS 中的**过滤器**。\nAngularJS 中的很多内置过滤器在 Angular 中都有对应的管道。\n要了解管道的更多信息,参见[Pipes](guide/pipes)。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -546,7 +546,7 @@
},
{
"original": "The Angular `currency` pipe is similar although some of the parameters have changed.",
- "translation": "Angular的`currency`管道和1中很相似,只是有些参数变化了。",
+ "translation": "Angular 的 `currency` 管道和 1 中很相似,只是有些参数变化了。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -556,7 +556,7 @@
},
{
"original": "The Angular `date` pipe is similar.",
- "translation": "Angular的`date`管道和它很相似。",
+ "translation": "Angular 的 `date` 管道和它很相似。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -571,17 +571,17 @@
},
{
"original": "For performance reasons, no comparable pipe exists in Angular. Do all your filtering in the component. If you need the same filtering code in several templates, consider building a custom pipe.",
- "translation": "在Angular中,出于性能的考虑,并没有一个类似的管道。\n 过滤逻辑应该在组件中用代码实现。\n 如果它将被复用在几个模板中,可以考虑构建一个自定义管道。",
+ "translation": "在 Angular 中,出于性能的考虑,并没有一个类似的管道。\n 过滤逻辑应该在组件中用代码实现。\n 如果它将被复用在几个模板中,可以考虑构建一个自定义管道。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "Converts a JavaScript object into a JSON string. This is useful for debugging.",
- "translation": "把一个JavaScript对象转换成一个JSON字符串。这对调试很有用。",
+ "translation": "把一个 JavaScript 对象转换成一个 JSON 字符串。这对调试很有用。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "The Angular `json` pipe does the same thing.",
- "translation": "Angular的`json`管道做完全相同的事。",
+ "translation": "Angular 的 `json` 管道做完全相同的事。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -591,7 +591,7 @@
},
{
"original": "The `SlicePipe` does the same thing but the *order of the parameters is reversed*, in keeping\n with the JavaScript `Slice` method.\n The first parameter is the starting index; the second is the limit.\n As in AngularJS, coding this operation within the component instead could improve performance.",
- "translation": "`SlicePipe`做同样的事,但是*两个参数的顺序是相反的*,以便于JavaScript中的`slice`方法保持一致。\n 第一个参数是起始索引号,第二个参数是限制的数量。\n 和AngularJS中一样,如果们改用组件中的代码实现此操作,性能将会提升。",
+ "translation": "`SlicePipe` 做同样的事,但是*两个参数的顺序是相反的*,以便于 JavaScript 中的 `slice` 方法保持一致。\n 第一个参数是起始索引号,第二个参数是限制的数量。\n 和 AngularJS 中一样,如果们改用组件中的代码实现此操作,性能将会提升。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -601,7 +601,7 @@
},
{
"original": "The Angular `lowercase` pipe does the same thing.",
- "translation": "Angular的`lowercase`管道和1中的功能完全相同。",
+ "translation": "Angular 的 `lowercase` 管道和 1 中的功能完全相同。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -611,17 +611,17 @@
},
{
"original": "The Angular `number` pipe is similar.\n It provides more functionality when defining\n the decimal places, as shown in the second example above.",
- "translation": "Angular的`number`管道很相似。\n 但在指定小数点位置时,它提供了更多的功能,如第二个范例所示。",
+ "translation": "Angular 的 `number` 管道很相似。\n 但在指定小数点位置时,它提供了更多的功能,如第二个范例所示。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "Angular also has a `percent` pipe, which formats a number as a local percentage\n as shown in the third example.",
- "translation": "Angular还有一个`percent`管道,它把一个数组格式化为本地化的(local)百分比格式,如第三个范例所示。",
+ "translation": "Angular 还有一个 `percent` 管道,它把一个数组格式化为本地化的(local)百分比格式,如第三个范例所示。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "Displays the collection in the order specified by the expression.\n In this example, the movie title orders the `movieList`.",
- "translation": "使用表达式中所指定的方式对集合进行排序。\n 在这个例子中,`movieList`被根据movie的title排序了。",
+ "translation": "使用表达式中所指定的方式对集合进行排序。\n 在这个例子中,`movieList` 被根据 movie 的 title 排序了。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -631,7 +631,7 @@
},
{
"original": "For performance reasons, no comparable pipe exists in Angular.\n Instead, use component code to order or sort results. If you need the same ordering or sorting code in several templates, consider building a custom pipe.",
- "translation": "在Angular中,出于性能的考虑,并没有一个类似的管道。\n 排序逻辑应该在组件中用代码实现。\n 如果它将被复用在几个模板中,可以考虑构建一个自定义管道。",
+ "translation": "在 Angular 中,出于性能的考虑,并没有一个类似的管道。\n 排序逻辑应该在组件中用代码实现。\n 如果它将被复用在几个模板中,可以考虑构建一个自定义管道。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -641,22 +641,22 @@
},
{
"original": "In both AngularJS and Angular, modules help you organize your application into cohesive blocks of functionality.",
- "translation": "无论在AngularJS还是Angular中,我们都要借助“模块”来把应用拆分成一些紧密相关的功能块。",
+ "translation": "无论在 AngularJS 还是 Angular 中,你都要借助“模块”来把应用拆分成一些紧密相关的功能块。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In AngularJS, you write the code that provides the model and the methods for the view in a **controller**.\nIn Angular, you build a **component**.",
- "translation": "在AngularJS中,我们在**控制器**中写代码,来为视图提供模型和方法。\n在Angular中,我们创建**组件**。",
+ "translation": "在 AngularJS 中,你要在**控制器**中写代码,来为视图提供模型和方法。\n在 Angular 中,你要创建**组件**。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "Because much AngularJS code is in JavaScript, JavaScript code is shown in the AngularJS column.\nThe Angular code is shown using TypeScript.",
- "translation": "因为很多AngularJS的代码是用JavaScript写的,所以在AngularJS列显示的是JavaScript代码,而Angular列显示的是TypeScript代码。",
+ "translation": "因为很多 AngularJS 的代码是用 JavaScript 写的,所以在 AngularJS 列显示的是 JavaScript 代码,而 Angular 列显示的是 TypeScript 代码。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In AngularJS, an immediately invoked function expression (or IIFE) around controller code\n keeps it out of the global namespace.",
- "translation": "在AngularJS中,用立即调用的函数表达式(IIFE)来包裹控制器代码可以让控制器代码不会污染全局命名空间。",
+ "translation": "在 AngularJS 中,用立即调用的函数表达式(IIFE)来包裹控制器代码可以让控制器代码不会污染全局命名空间。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -666,7 +666,7 @@
},
{
"original": "This is a nonissue in Angular because ES 2015 modules\n handle the namespacing for you.",
- "translation": "在Angular中我们不用担心这个问题,因为使用ES 2015的模块,模块会替我们处理命名空间问题。",
+ "translation": "在 Angular 中不用担心这个问题,因为使用 ES 2015 的模块,模块会替你处理命名空间问题。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -676,17 +676,17 @@
},
{
"original": "### Angular modules",
- "translation": "### Angular模块",
+ "translation": "### Angular 模块",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In AngularJS, an Angular module keeps track of controllers, services, and other code.\n The second argument defines the list of other modules that this module depends upon.",
- "translation": "在AngularJS中,Angular模块用来对控制器、服务和其它代码进行跟踪。第二个参数定义该模块依赖的其它模块列表。",
+ "translation": "在 AngularJS 中,Angular 模块用来对控制器、服务和其它代码进行跟踪。第二个参数定义该模块依赖的其它模块列表。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "NgModules, defined with the `NgModule` decorator, serve the same purpose:",
- "translation": "Angular的模块用`NgModule`装饰器进行定义,有如下用途:",
+ "translation": "Angular 的模块用 `NgModule` 装饰器进行定义,有如下用途:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -711,7 +711,7 @@
},
{
"original": "AngularJS has code in each controller that looks up an appropriate Angular module\n and registers the controller with that module.",
- "translation": "在AngularJS中,在每个控制器中都有一些代码,用于找到合适的Angular模块并把该控制器注册进去。",
+ "translation": "在 AngularJS 中,在每个控制器中都有一些代码,用于找到合适的 Angular 模块并把该控制器注册进去。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -726,7 +726,7 @@
},
{
"original": "Angular adds a decorator to the component class to provide any required metadata.\n The `@Component` decorator declares that the class is a component and provides metadata about\n that component such as its selector (or tag) and its template.",
- "translation": "在Angular中,我们往组件类上添加了一个装饰器,以提供任何需要的元数据。\n `@Component`装饰器把该类声明为组件,并提供了关于该组件的元数据,比如它的选择器(或标签)和模板。",
+ "translation": "Angular 会往组件类上添加了一个装饰器,以提供所需的任何元数据。\n `@Component` 装饰器把该类声明为组件,并提供了关于该组件的元数据,比如它的选择器(或标签)和模板。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -746,7 +746,7 @@
},
{
"original": "In AngularJS, you write the code for the model and methods in a controller function.",
- "translation": "在Angular1中,我们在控制器函数中写模型和方法的代码。",
+ "translation": "在 Angular1 中,你在控制器函数中编写模型和方法的代码。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -756,12 +756,12 @@
},
{
"original": "In Angular, you create a component class.",
- "translation": "在Angular中,我们写组件类。",
+ "translation": "在 Angular 中,你要创建组件类。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "NOTE: If you are using TypeScript with AngularJS, you must use the `export` keyword to export the component class.",
- "translation": "注意:如果你正在用TypeScript写AngularJS,那么必须用`export`关键字来导出组件类。",
+ "translation": "注意:如果你正在用 TypeScript 写 AngularJS,那么必须用 `export` 关键字来导出组件类。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -776,12 +776,12 @@
},
{
"original": "In AngularJS, you pass in any dependencies as controller function arguments.\n This example injects a `MovieService`.",
- "translation": "在AngularJS中,我们把所有依赖都作为控制器函数的参数。\n 在这个例子中,我们注入了一个`MovieService`。",
+ "translation": "在 AngularJS 中,你把所有依赖都作为控制器函数的参数。\n 这个例子注入了一个 `MovieService`。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "To guard against minification problems, tell Angular explicitly\n that it should inject an instance of the `MovieService` in the first parameter.",
- "translation": "我们还通过在第一个参数明确告诉Angular它应该注入一个`MovieService`的实例,以防止在最小化时出现问题。",
+ "translation": "为了防止在最小化时出现问题,第一个参数明确告诉 Angular 它应该注入一个 `MovieService` 的实例。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -791,7 +791,7 @@
},
{
"original": "In Angular, you pass in dependencies as arguments to the component class constructor.\n This example injects a `MovieService`.\n The first parameter's TypeScript type tells Angular what to inject, even after minification.",
- "translation": "在Angular中,我们把依赖作为组件构造函数的参数传入。\n 在这个例子中,我们注入了一个`MovieService`。\n 即使在最小化之后,第一个参数的TypeScript类型也会告诉Angular它该注入什么。",
+ "translation": "在 Angular 中,你要把依赖作为组件构造函数的参数传入。\n 这个例子注入了一个 `MovieService`。\n 即使在最小化之后,第一个参数的 TypeScript 类型也会告诉 Angular 它该注入什么。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -806,17 +806,17 @@
},
{
"original": "Style sheets give your application a nice look.\nIn AngularJS, you specify the style sheets for your entire application.\nAs the application grows over time, the styles for the many parts of the application\nmerge, which can cause unexpected results.\nIn Angular, you can still define style sheets for your entire application. But now you can\nalso encapsulate a style sheet within a specific component.",
- "translation": "样式表美化我们的应用程序。\n在AngularJS中,我们为整个应用程序指定样式表。\n当应用程序成长一段时间之后,应用程序中很多部分的样式会被合并,导致无法预计的后果。\n在Angular中,我们仍然会为整个应用程序定义样式,不过现在也可以把样式表封装在特定的组件中。",
+ "translation": "样式表让你的应用程序看起来更漂亮。\n在 AngularJS 中,你要为整个应用程序指定样式表。\n随着应用程序的不断成长,为各个部分指定的样式会被合并,导致无法预计的后果。\n在 Angular 中,你仍然要为整个应用程序定义样式,不过现在也可以把样式表封装在特定的组件中。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "### Link tag",
- "translation": "### Link标签",
+ "translation": "### Link 标签",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "AngularJS, uses a `link` tag in the head section of the `index.html` file\n to define the styles for the application.",
- "translation": "在AngularJS中,我们在`index.html`的`head`区使用`link`标签来为应用程序定义样式。",
+ "translation": "AngularJS 在 `index.html` 的 `head` 区使用 `link` 标签来为应用程序定义样式。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -826,17 +826,17 @@
},
{
"original": "With the Angular CLI, you can configure your global styles in the `.angular-cli.json` file.\n You can rename the extension to `.scss` to use sass.",
- "translation": "使用 Angular CLI,我们可以在 `.angular-cli.json` 文件中配置全局样式。\n 也可以把扩展名改为 `.scss` 来使用 sass。",
+ "translation": "使用 Angular CLI,你可以在 `.angular-cli.json` 文件中配置全局样式。\n 也可以把扩展名改为 `.scss` 来使用 sass。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "In Angular, you can use the `styles` or `styleUrls` property of the `@Component` metadata to define\n a style sheet for a particular component.",
- "translation": "在Angular中,我们可以在`@Component`的元数据中使用`styles`或`styleUrls`属性来为一个特定的组件定义样式表。",
+ "translation": "在 Angular 中,你可以在 `@Component` 的元数据中使用 `styles` 或 `styleUrls` 属性来为一个特定的组件定义样式表。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
"original": "This allows you to set appropriate styles for individual components that won’t leak into\n other parts of the application.",
- "translation": "这让我们可以为各个组件设置合适的样式,而不用担心它被泄漏到程序中的其它部分。",
+ "translation": "这让你可以为各个组件设置合适的样式,而不用担心它被泄漏到程序中的其它部分。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ajs-quick-reference.md"
},
{
@@ -846,7 +846,7 @@
},
{
"original": "Motion is an important aspect in the design of modern web applications. Good\nuser interfaces transition smoothly between states with engaging animations\nthat call attention where it's needed. Well-designed animations can make a UI not only\nmore fun but also easier to use.",
- "translation": "动画是现代Web应用设计中一个很重要的方面。我们希望用户界面能在不同的状态之间更平滑的转场。如果需要,还可以用适当的动画来吸引注意力。\n设计良好的动画不但会让UI更有趣,还会让它更容易使用。",
+ "translation": "动画是现代 Web 应用设计中一个很重要的方面。好的用户界面要能在不同的状态之间更平滑的转场。如果需要,还可以用适当的动画来吸引注意力。\n设计良好的动画不但会让 UI 更有趣,还会让它更容易使用。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -856,12 +856,12 @@
},
{
"original": "Angular's animation system lets you build animations that run with the same kind of native\nperformance found in pure CSS animations. You can also tightly integrate your\nanimation logic with the rest of your application code, for ease of control.",
- "translation": "Angular的动画系统赋予了制作各种动画效果的能力,以构建出与原生CSS动画性能相同的动画。\n我们也获得了额外的让动画逻辑与其它应用代码紧紧集成在一起的能力,这让动画可以被更容易的触发与控制。",
+ "translation": "Angular 的动画系统赋予了制作各种动画效果的能力,以构建出与原生 CSS 动画性能相同的动画。\n你还获得了额外的让动画逻辑与其它应用代码紧紧集成在一起的能力,这让动画可以被更容易的触发与控制。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "Angular animations are built on top of the standard [Web Animations API](https://w3c.github.io/web-animations/)\nand run natively on [browsers that support it](http://caniuse.com/#feat=web-animation).",
- "translation": "Angular动画是基于标准的[Web动画API(Web Animations API)](https://w3c.github.io/web-animations/)构建的,它们在[支持此API的浏览器中](http://caniuse.com/#feat=web-animation)会用原生方式工作。",
+ "translation": "Angular 动画是基于标准的[Web 动画 API(Web Animations API)](https://w3c.github.io/web-animations/)构建的,它们在[支持此 API 的浏览器中](http://caniuse.com/#feat=web-animation)会用原生方式工作。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -911,32 +911,32 @@
},
{
"original": "You can build a simple animation that transitions an element between two states\ndriven by a model attribute.",
- "translation": "我们来构建一个简单的动画,它会让一个元素用模型驱动的方式在两个状态之间转场。",
+ "translation": "你可以构建一个简单的动画,它会让一个元素用模型驱动的方式在两个状态之间转场。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "Animations can be defined inside `@Component` metadata.",
- "translation": "动画会被定义在`@Component`元数据中。",
+ "translation": "动画会被定义在 `@Component` 元数据中。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "With these, you can define an *animation trigger* called `heroState` in the component\nmetadata. It uses animations to transition between two states: `active` and `inactive`. When a\nhero is active, the element appears in a slightly larger size and lighter color.",
- "translation": "通过这些,可以在组件元数据中定义一个名叫`heroState`的*动画触发器*。它在两个状态`active`和`inactive`之间进行转场。\n当英雄处于激活状态时,它会把该元素显示得稍微大一点、亮一点。",
+ "translation": "通过这些,可以在组件元数据中定义一个名叫 `heroState` 的*动画触发器*。它在两个状态 `active` 和 `inactive` 之间进行转场。\n当英雄处于激活状态时,它会把该元素显示得稍微大一点、亮一点。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "In this example, you are defining animation styles (color and transform) inline in the\nanimation metadata.",
- "translation": "在这个例子中,我们在元数据中用内联的方式定义了动画样式(`color`和`transform`)。在即将到来的一个Angular版本中,还将支持从组件的CSS样式表中提取样式。",
+ "translation": "在这个例子中,你在元数据中用内联的方式定义了动画样式(`color` 和 `transform`)。在即将到来的一个 Angular 版本中,还将支持从组件的 CSS 样式表中提取样式。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "Now, using the `[@triggerName]` syntax, attach the animation that you just defined to\none or more elements in the component's template.",
- "translation": "我们刚刚定义了一个动画,但它还没有被用到任何地方。要想使用它,可以在模板中用`[@triggerName]`语法来把它附加到一个或多个元素上。",
+ "translation": "现在,使用 `[@triggerName]` 语法来把刚刚定义的动画附加到组件模板中一个或多个元素上。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "Here, the animation trigger applies to every element repeated by an `ngFor`. Each of\nthe repeated elements animates independently. The value of the\nattribute is bound to the expression `hero.state` and is always either `active` or `inactive`.",
- "translation": "这里,我们把该动画触发器添加到了由`ngFor`重复出来的每一个元素上。每个重复出来的元素都有独立的动画效果。\n然后把`@triggerName`属性(Attribute)的值设置成表达式`hero.state`。这个值应该或者是`inactive`或者是`active`,因为我们刚刚为它们俩定义过动画状态。",
+ "translation": "这里,动画触发器被添加到了由 `ngFor` 重复出来的每一个元素上。每个重复出来的元素都有独立的动画效果。\n然后把 `@triggerName` 属性(Attribute)的值设置成表达式 `hero.state`。这个值应该是 `inactive` 或 `active` 之一。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -951,22 +951,22 @@
},
{
"original": "Angular animations are defined as logical **states** and **transitions**\nbetween states.",
- "translation": "Angular动画是由**状态**和**状态之间的转场效果**所定义的。",
+ "translation": "Angular 动画是由**状态**和**状态之间的转场效果**所定义的。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "An animation state is a string value that you define in your application code. In the example\nabove, the states `'active'` and `'inactive'` are based on the logical state of\nhero objects. The source of the state can be a simple object attribute, as it was in this case,\nor it can be a value computed in a method. The important thing is that you can read it into the\ncomponent's template.",
- "translation": "动画状态是一个由程序代码中定义的字符串值。在上面的例子中,基于英雄对象的逻辑状态,我们使用了`'active'`和`'inactive'`这两种状态。\n状态的来源可以是像本例中这样简单的对象属性,也可以是由方法计算出来的值。重点是,我们得能从组件模板中读取它。",
+ "translation": "动画状态是一个由程序代码中定义的字符串值。在上面的例子中,`'active'` 和 `'inactive'` 是基于英雄对象的逻辑状态的。\n状态的来源可以是像本例中这样简单的对象属性,也可以是由方法计算出来的值。重点是,你要能从组件模板中读取它。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "You can define *styles* for each animation state:",
- "translation": "我们可以为每个动画状态定义了*一组样式*:",
+ "translation": "你可以为每个动画状态定义了*一组样式*:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "These `state` definitions specify the *end styles* of each state.\nThey are applied to the element once it has transitioned to that state, and stay\n*as long as it remains in that state*. In effect, you're defining what styles the element has in different states.",
- "translation": "这些`state`具体定义了每个状态的*最终样式*。一旦元素转场到那个状态,该样式就会被应用到此元素上,*当它留在此状态时*,这些样式也会一直保持着。\n从这个意义上讲,这里其实并不只是在定义动画,而是在定义该元素在不同状态时应该具有的样式。",
+ "translation": "这些 `state` 具体定义了每个状态的*最终样式*。一旦元素转场到那个状态,该样式就会被应用到此元素上,*当它留在此状态时*,这些样式也会一直保持着。\n从这个意义上讲,这里其实并不只是在定义动画,而是在定义该元素在不同状态时应该具有的样式。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -976,17 +976,17 @@
},
{
"original": "If several transitions have the same timing configuration, you can combine\nthem into the same `transition` definition:",
- "translation": "如果多个转场都有同样的时间线配置,就可以把它们合并进同一个`transition`定义中:",
+ "translation": "如果多个转场都有同样的时间线配置,就可以把它们合并进同一个 `transition` 定义中:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "When both directions of a transition have the same timing, as in the previous\nexample, you can use the shorthand syntax `<=>`:",
- "translation": "如果要对同一个转场的两个方向都使用相同的时间线(就像前面的例子中那样),就可以使用`<=>`这种简写语法:",
+ "translation": "如果要对同一个转场的两个方向都使用相同的时间线(就像前面的例子中那样),就可以使用 `<=>` 这种简写语法:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "You can also apply a style during an animation but not keep it around\nafter the animation finishes. You can define such styles inline, in the `transition`. In this example,\nthe element receives one set of styles immediately and is then animated to the next.\nWhen the transition finishes, none of these styles are kept because they're not\ndefined in a `state`.",
- "translation": "有时希望一些样式只在动画期间生效,但在结束后并不保留它们。这时可以把这些样式内联在`transition`中进行定义。\n在这个例子中,该元素会立刻获得一组样式,然后动态转场到下一个状态。当转场结束时,这些样式并不会被保留,因为它们并没有被定义在`state`中。",
+ "translation": "有时希望一些样式只在动画期间生效,但在结束后并不保留它们。这时可以把这些样式内联在 `transition` 中进行定义。\n在这个例子中,该元素会立刻获得一组样式,然后动态转场到下一个状态。当转场结束时,这些样式并不会被保留,因为它们并没有被定义在 `state` 中。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -1001,32 +1001,32 @@
},
{
"original": "* The `active => *` transition applies when the element's state changes from `active` to anything else.",
- "translation": "当该元素的状态从`active`变成任何其它状态时,`active => *`转场都会生效。",
+ "translation": "当该元素的状态从 `active` 变成任何其它状态时,`active => *` 转场都会生效。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "* The `* => *` transition applies when *any* change between two states takes place.",
- "translation": "当在*任意*两个状态之间切换时,`* => *`转场都会生效。",
+ "translation": "当在*任意*两个状态之间切换时,`* => *` 转场都会生效。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "### The `void` state",
- "translation": "### `void`状态",
+ "translation": "### `void` 状态",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "The special state called `void` can apply to any animation. It applies\nwhen the element is *not* attached to a view, perhaps because it has not yet been\nadded or because it has been removed. The `void` state is useful for defining enter and\nleave animations.",
- "translation": "有一种叫做`void`的特殊状态,它可以应用在任何动画中。它表示元素*没有*被附加到视图。这种情况可能是由于它尚未被添加进来或者已经被移除了。\n`void`状态在定义“进场”和“离场”的动画时会非常有用。",
+ "translation": "有一种叫做 `void` 的特殊状态,它可以应用在任何动画中。它表示元素*没有*被附加到视图。这种情况可能是由于它尚未被添加进来或者已经被移除了。\n`void` 状态在定义“进场”和“离场”的动画时会非常有用。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "For example the `* => void` transition applies when the element leaves the view,\nregardless of what state it was in before it left.",
- "translation": "比如当一个元素离开视图时,`* => void`转场就会生效,而不管它在离场以前是什么状态。",
+ "translation": "比如当一个元素离开视图时,`* => void` 转场就会生效,而不管它在离场以前是什么状态。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "The wildcard state `*` also matches `void`.",
- "translation": "`*`通配符状态也能匹配`void`。",
+ "translation": "`*` 通配符状态也能匹配 `void`。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -1036,7 +1036,7 @@
},
{
"original": "Using the `void` and `*` states you can define transitions that animate the\nentering and leaving of elements:",
- "translation": "使用`void`和`*`状态,可以定义元素进场与离场时的转场动画:",
+ "translation": "使用 `void` 和 `*` 状态,可以定义元素进场与离场时的转场动画:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -1051,12 +1051,12 @@
},
{
"original": "For example, in the `animations` array below there are two transitions that use\nthe `void => *` and `* => void` syntax to animate the element in and out of the view.",
- "translation": "例如,在下面的`animations`数组中,这两个转场语句使用`void => *`和`* => void`语法来让该元素以动画形式进入和离开当前视图。",
+ "translation": "例如,在下面的 `animations` 数组中,这两个转场语句使用 `void => *` 和 `* => void` 语法来让该元素以动画形式进入和离开当前视图。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "Note that in this case the styles are applied to the void state directly in the\ntransition definitions, and not in a separate `state(void)` definition. Thus, the transforms\nare different on enter and leave: the element enters from the left\nand leaves to the right.",
- "translation": "注意,在这个例子中,这些样式在转场定义中被直接应用到了`void`状态,但并没有一个单独的`state(void)`定义。\n这么做是因为希望在进场与离场时使用不一样的转换效果:元素从左侧进场,从右侧离开。",
+ "translation": "注意,在这个例子中,这些样式在转场定义中被直接应用到了 `void` 状态,但并没有一个单独的 `state(void)` 定义。\n这么做是因为希望在进场与离场时使用不一样的转换效果:元素从左侧进场,从右侧离开。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -1071,7 +1071,7 @@
},
{
"original": "You can also combine this animation with the earlier state transition animation by\nusing the hero state as the animation state. This lets you configure\ndifferent transitions for entering and leaving based on what the state of the hero\nis:",
- "translation": "通过把英雄的状态用作动画的状态,还能把该动画跟以前的转场动画组合成一个复合动画。这让我们能根据该英雄的当前状态为其配置不同的进场与离场动画:",
+ "translation": "通过把英雄的状态用作动画的状态,还能把该动画跟以前的转场动画组合成一个复合动画。这让你能根据该英雄的当前状态为其配置不同的进场与离场动画:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -1106,7 +1106,7 @@
},
{
"original": "Since Angular's animation support builds on top of Web Animations, you can animate any property\nthat the browser considers *animatable*. This includes positions, sizes, transforms, colors,\nborders, and many others. The W3C maintains\n[a list of animatable properties](https://www.w3.org/TR/css3-transitions/#animatable-properties)\non its [CSS Transitions page](https://www.w3.org/TR/css3-transitions).",
- "translation": "由于Angular的动画支持是基于Web Animations标准的,所以也能支持浏览器认为可以*参与动画*的任何属性。这些属性包括位置(position)、大小(size)、变换(transform)、颜色(color)、边框(border)等很多属性。W3C维护着\n[一个“可动”属性列表](https://www.w3.org/TR/css3-transitions/#animatable-properties)。",
+ "translation": "由于 Angular 的动画支持是基于 Web Animations 标准的,所以也能支持浏览器认为可以*参与动画*的任何属性。这些属性包括位置(position)、大小(size)、变换(transform)、颜色(color)、边框(border)等很多属性。W3C 维护着\n[一个“可动”属性列表](https://www.w3.org/TR/css3-transitions/#animatable-properties)。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -1121,7 +1121,7 @@
},
{
"original": "* `50` is the same as saying `'50px'`",
- "translation": "`50`相当于`'50px'`",
+ "translation": "`50` 相当于 `'50px'`",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -1131,17 +1131,17 @@
},
{
"original": "Sometimes you don't know the value of a dimensional style property until runtime.\nFor example, elements often have widths and heights that\ndepend on their content and the screen size. These properties are often tricky\nto animate with CSS.",
- "translation": "有时候,我们想在动画中使用的尺寸类样式,它的值在开始运行之前都是不可知的。比如,元素的宽度和高度往往依赖于它们的内容和屏幕的尺寸。处理这些属性对CSS动画而言通常是相当棘手的。",
+ "translation": "有时候,你在开始运行之前都无法知道某个样式属性的值。比如,元素的宽度和高度往往依赖于它们的内容和屏幕的尺寸。处理这些属性对 CSS 动画而言通常是相当棘手的。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "In these cases, you can use a special `*` property value so that the value of the\nproperty is computed at runtime and then plugged into the animation.",
- "translation": "如果用Angular动画,就可以用一个特殊的`*`属性值来处理这种情况。该属性的值将会在运行期被计算出来,然后插入到这个动画中。",
+ "translation": "如果用 Angular 动画,就可以用一个特殊的 `*` 属性值来处理这种情况。该属性的值将会在运行期被计算出来,然后插入到这个动画中。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "In this example, the leave animation takes whatever height the element has before it\nleaves and animates from that height to zero:",
- "translation": "这个例子中的“离场”动画会取得该元素在离场前的高度,并且把它从这个高度用动画转场到0高度:",
+ "translation": "这个例子中的“离场”动画会取得该元素在离场前的高度,并且把它从这个高度用动画转场到 0 高度:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -1191,7 +1191,7 @@
},
{
"original": "* Wait for 100ms and then run for 200ms: `'0.2s 100ms'`",
- "translation": "等待100毫秒,然后运行200毫秒:`'0.2s 100ms'`。",
+ "translation": "等待 100 毫秒,然后运行 200 毫秒:`'0.2s 100ms'`。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -1201,17 +1201,17 @@
},
{
"original": "The [easing function](http://easings.net/) controls how the animation accelerates\nand decelerates during its runtime. For example, an `ease-in` function causes\nthe animation to begin relatively slowly but pick up speed as it progresses. You\ncan control the easing by adding it as a *third* value in the string after the duration\nand the delay (or as the *second* value when there is no delay):",
- "translation": "[缓动函数](http://easings.net/)用于控制动画在运行期间如何加速和减速。比如:使用`ease-in`函数意味着动画开始时相对缓慢,然后在进行中逐步加速。可以通过在这个字符串中的持续时间和延迟后面添加*第三个*值来控制使用哪个缓动函数(如果没有定义延迟就作为*第二个*值)。",
+ "translation": "[缓动函数](http://easings.net/)用于控制动画在运行期间如何加速和减速。比如:使用 `ease-in` 函数意味着动画开始时相对缓慢,然后在进行中逐步加速。可以通过在这个字符串中的持续时间和延迟后面添加*第三个*值来控制使用哪个缓动函数(如果没有定义延迟就作为*第二个*值)。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "* Wait for 100ms and then run for 200ms, with easing: `'0.2s 100ms ease-out'`",
- "translation": "等待100毫秒,然后运行200毫秒,并且带缓动:`'0.2s 100ms ease-out'`",
+ "translation": "等待 100 毫秒,然后运行 200 毫秒,并且带缓动:`'0.2s 100ms ease-out'`",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "* Run for 200ms, with easing: `'0.2s ease-in-out'`",
- "translation": "运行200毫秒,并且带缓动:`'0.2s ease-in-out'`",
+ "translation": "运行 200 毫秒,并且带缓动:`'0.2s ease-in-out'`",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -1221,7 +1221,7 @@
},
{
"original": "Here are a couple of custom timings in action. Both enter and leave last for\n200 milliseconds, that is `0.2s`, but they have different easings. The leave begins after a\nslight delay of 10 milliseconds as specified in `'0.2s 10 ease-out'`:",
- "translation": "这里是两个自定义时间线的动态演示。“进场”和“离场”都持续200毫秒,也就是`0.2s`,但它们有不同的缓动函数。“离场”动画会在100毫秒的延迟之后开始,也就是`'0.2s 10 ease-out'`:",
+ "translation": "这里是两个自定义时间线的动态演示。“进场”和“离场”都持续 200 毫秒,也就是 `0.2s`,但它们有不同的缓动函数。“离场”动画会在 100 毫秒的延迟之后开始,也就是 `'0.2s 10 ease-out'`:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -1236,22 +1236,22 @@
},
{
"original": "For each keyframe, you specify an *offset* that defines at which point\nin the animation that keyframe applies. The offset is a number between zero,\nwhich marks the beginning of the animation, and one, which marks the end.",
- "translation": "每个关键帧都可以被指定一个*偏移量*,用来定义该关键帧将被用在动画期间的哪个时间点。偏移量是一个介于0(表示动画起点)和1(表示动画终点)之间的数组。",
+ "translation": "每个关键帧都可以被指定一个*偏移量*,用来定义该关键帧将被用在动画期间的哪个时间点。偏移量是一个介于 0(表示动画起点)和 1(表示动画终点)之间的数组。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "This example adds some \"bounce\" to the enter and leave animations with\nkeyframes:",
- "translation": "在这个例子中,我们使用关键帧来为进场和离场动画添加一些“反弹效果”:",
+ "translation": "这个例子使用关键帧来为进场和离场动画添加一些“反弹效果”:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "Note that the offsets are *not* defined in terms of absolute time. They are relative\nmeasures from zero to one. The final timeline of the animation is based on the combination\nof keyframe offsets, duration, delay, and easing.",
- "translation": "注意,这个偏移量并*不是*用绝对数字定义的时间段,而是在0到1之间的相对值(百分比)。动画的最终时间线会基于关键帧的偏移量、持续时间、延迟和缓动函数计算出来。",
+ "translation": "注意,这个偏移量并*不是*用绝对数字定义的时间段,而是在 0 到 1 之间的相对值(百分比)。动画的最终时间线会基于关键帧的偏移量、持续时间、延迟和缓动函数计算出来。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "Defining offsets for keyframes is optional. If you omit them, offsets with even\nspacing are automatically assigned. For example, three keyframes without predefined\noffsets receive offsets `0`, `0.5`, and `1`.",
- "translation": "为关键帧定义偏移量是可选的。如果省略它们,偏移量会自动根据帧数平均分布出来。例如,三个未定义过偏移量的关键帧会分别获得偏移量:`0`、`0.5`和`1`。",
+ "translation": "为关键帧定义偏移量是可选的。如果省略它们,偏移量会自动根据帧数平均分布出来。例如,三个未定义过偏移量的关键帧会分别获得偏移量:`0`、`0.5` 和 `1`。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -1261,22 +1261,22 @@
},
{
"original": "You've seen how to animate multiple style properties at the same time:\njust put all of them into the same `style()` definition.",
- "translation": "我们已经知道该如何在同一时间段进行多个样式的动画了:只要把它们都放进同一个`style()`定义中就行了!",
+ "translation": "你已经知道该如何在同一时间段进行多个样式的动画了:只要把它们都放进同一个 `style()` 定义中就行了!",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "But you may also want to configure different *timings* for animations that happen\nin parallel. For example, you may want to animate two CSS properties but use a\ndifferent easing function for each one.",
- "translation": "但我们也可能会希望为同时发生的几个动画配置不同的*时间线*。比如,同时对两个CSS属性做动画,但又得为它们定义不同的缓动函数。",
+ "translation": "但你也可能会希望为同时发生的几个动画配置不同的*时间线*。比如,同时对两个 CSS 属性做动画,但又得为它们定义不同的缓动函数。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "For this you can use animation *groups*. In this example, using groups both on\nenter and leave allows for two different timing configurations. Both\nare applied to the same element in parallel, but run independently of each other:",
- "translation": "这种情况下就可以用动画*组*来解决了。在这个例子中,我们同时在进场和离场时使用了组,以便能让它们使用两种不同的时间线配置。\n它们被同时应用到同一个元素上,但又彼此独立运行:",
+ "translation": "这种情况下就可以用动画*组*来解决了。在这个例子中,同时在进场和离场时使用了组,以便能让它们使用两种不同的时间线配置。\n它们被同时应用到同一个元素上,但又彼此独立运行:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "One group animates the element transform and width; the other group animates the opacity.",
- "translation": "其中一个动画组对元素的`transform`和`width`做动画,另一个组则对`opacity`做动画。",
+ "translation": "其中一个动画组对元素的 `transform` 和 `width` 做动画,另一个组则对 `opacity` 做动画。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -1291,12 +1291,12 @@
},
{
"original": "In the keyframes example, you have a `trigger` called `@flyInOut`. You can hook\nthose callbacks like this:",
- "translation": "对于例子中的这个关键帧,我们有一个叫做`@flyInOut`的`trigger`。在那里我们可以挂钩到那些回调,比如:",
+ "translation": "对于例子中的这个关键帧,你有一个叫做 `@flyInOut` 的 `trigger`。在那里你可以挂钩到那些回调,比如:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
"original": "The callbacks receive an `AnimationEvent` that contains useful properties such as\n`fromState`, `toState` and `totalTime`.",
- "translation": "这些回调接收一个`AnimationTransitionEvent`参数,它包含一些有用的属性,例如`fromState`,`toState`和`totalTime`。",
+ "translation": "这些回调接收一个 `AnimationTransitionEvent` 参数,它包含一些有用的属性,例如 `fromState`,`toState` 和 `totalTime`。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
{
@@ -1304,6 +1304,11 @@
"translation": "无论动画是否实际执行过,那些回调都会触发。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/animations.md"
},
+ {
+ "original": "# The Ahead-of-Time (AOT) Compiler",
+ "translation": "# 预先(AOT)编译",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
{
"original": "The Angular Ahead-of-Time (AOT) compiler converts your Angular HTML and TypeScript code into efficient JavaScript code during the build phase _before_ the browser downloads and runs that code.",
"translation": "Angular 的“预先(AOT)编译器”会在构建期间把 Angular 应用的 HTML 和 TypeScript 代码编译成高效的 JavaScript 代码,之后浏览器就可以下载并快速运行这些代码。",
@@ -1316,7 +1321,7 @@
},
{
"original": "Watch compiler author Tobias Bosch explain the Angular Compiler at AngularConnect 2016.",
- "translation": "观看编译器作者Tobias Bosch在AngularConnect 2016大会里,对Angular编译器的演讲。",
+ "translation": "观看编译器作者 Tobias Bosch 在 AngularConnect 2016 大会里,对Angular 编译器的演讲。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
@@ -1324,6 +1329,41 @@
"translation": "## Angular 中的编译",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
+ {
+ "original": "An Angular application consists largely of components and their HTML templates.\nBefore the browser can render the application,\nthe components and templates must be converted to executable JavaScript by an _Angular compiler_.",
+ "translation": "Angular 应用由大量组件及其 HTML 模板组成。\n在浏览器渲染应用之前,组件和模板必须由 *Angular 编译器*转换成可执行的 JavaScript 代码。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Angular offers two ways to compile your application:",
+ "translation": "Angular 提供了两种方式来编译你的应用:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "1. **_Just-in-Time_ (JIT)**, which compiles your app in the browser at runtime",
+ "translation": "**即时(JIT)编译**,它会在浏览器中运行时编译你的应用",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "1. **_Ahead-of-Time_ (AOT)**, which compiles your app at build time.",
+ "translation": "**预先(AOT)编译**,它会在构建时编译你的应用。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "JIT compilation is the default when you run the _build-only_ or the _build-and-serve-locally_ CLI commands:",
+ "translation": "当你运行 *`build`* 或 *`serve`* 这两个 CLI 命令时 JIT 编译是默认选项:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "For AOT compilation, append the `--aot` flags to the _build-only_ or the _build-and-serve-locally_ CLI commands:",
+ "translation": "要进行 AOT 编译只要给这两个 CLI 命令添加 `--aot` 标志就行了:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The `--prod` meta-flag compiles with AOT by default.",
+ "translation": "`--prod` 标志也会默认使用 AOT 编译。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
{
"original": "See the [CLI documentation](https://github.com/angular/angular-cli/wiki) for details, especially the [`build` topic](https://github.com/angular/angular-cli/wiki/build).",
"translation": "要了解更多,请参见[CLI 文档](https://github.com/angular/angular-cli/wiki),特别是[`build` 这个主题](https://github.com/angular/angular-cli/wiki/build)。",
@@ -1331,7 +1371,7 @@
},
{
"original": "## Why compile with AOT?",
- "translation": "## 为什么需要AOT编译?",
+ "translation": "## 为什么需要 AOT 编译?",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
@@ -1341,7 +1381,7 @@
},
{
"original": "With AOT, the browser downloads a pre-compiled version of the application.\nThe browser loads executable code so it can render the application immediately, without waiting to compile the app first.",
- "translation": "使用AOT,浏览器下载预编译版本的应用程序。\n浏览器直接加载运行代码,所以它可以立即渲染该应用,而不用等应用完成首次编译。",
+ "translation": "使用 AOT,浏览器下载预编译版本的应用程序。\n浏览器直接加载运行代码,所以它可以立即渲染该应用,而不用等应用完成首次编译。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
@@ -1351,17 +1391,17 @@
},
{
"original": "The compiler _inlines_ external HTML templates and CSS style sheets within the application JavaScript,\neliminating separate ajax requests for those source files.",
- "translation": "编译器把外部HTML模板和CSS样式表内联到了该应用的JavaScript中。\n消除了用来下载那些源文件的Ajax请求。",
+ "translation": "编译器把外部 HTML 模板和 CSS 样式表内联到了该应用的 JavaScript 中。\n消除了用来下载那些源文件的 Ajax 请求。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
"original": "*Smaller Angular framework download size*",
- "translation": "**需要下载的Angular框架体积更小**",
+ "translation": "**需要下载的 Angular 框架体积更小**",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
"original": "There's no need to download the Angular compiler if the app is already compiled.\nThe compiler is roughly half of Angular itself, so omitting it dramatically reduces the application payload.",
- "translation": "如果应用已经编译过了,自然不需要再下载Angular编译器了。\n该编译器差不多占了Angular自身体积的一半儿,所以,省略它可以显著减小应用的体积。",
+ "translation": "如果应用已经编译过了,自然不需要再下载 Angular 编译器了。\n该编译器差不多占了 Angular 自身体积的一半儿,所以,省略它可以显著减小应用的体积。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
@@ -1371,7 +1411,7 @@
},
{
"original": "The AOT compiler detects and reports template binding errors during the build step\nbefore users can see them.",
- "translation": "AOT编译器在构建过程中检测和报告模板绑定错误,避免用户遇到这些错误。",
+ "translation": "AOT 编译器在构建过程中检测和报告模板绑定错误,避免用户遇到这些错误。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
@@ -1381,7 +1421,162 @@
},
{
"original": "AOT compiles HTML templates and components into JavaScript files long before they are served to the client.\nWith no templates to read and no risky client-side HTML or JavaScript evaluation,\nthere are fewer opportunities for injection attacks.",
- "translation": "AOT编译远在HTML模版和组件被服务到客户端之前,将它们编译到JavaScript文件。\n没有模版可以阅读,没有高风险客户端HTML或JavaScript可利用,所以注入攻击的机会较少。",
+ "translation": "AOT 编译远在 HTML 模版和组件被服务到客户端之前,将它们编译到 JavaScript 文件。\n没有模版可以阅读,没有高风险客户端 HTML 或 JavaScript 可利用,所以注入攻击的机会较少。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "## Angular Compiler Options",
+ "translation": "## Angular 编译器选项",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "You can control your app compilation by providing template compiler options in the `tsconfig.json` file along with the options supplied to the TypeScript compiler. The template compiler options are specified as members of\n`\"angularCompilerOptions\"` object as shown below:",
+ "translation": "你可以通过在 `tsconfig.json` 文件中随 TypeScript 编译选项一起提供模板编译选项来控制应用的编译方式。\n这些模板编译选项都是作为 `\"angularCompilerOptions\"` 对象的成员指定的,代码如下:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This option tells the compiler not to produce `.metadata.json` files.\nThe option is `false` by default.",
+ "translation": "这个选项告诉编译器不要生成 `.metadata.json` 文件,它默认是 `false`。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "`.metadata.json` files contain information needed by the template compiler from a `.ts`\nfile that is not included in the `.d.ts` file produced by the TypeScript compiler. This information contains,\nfor example, the content of annotations (such as a component's template) which TypeScript\nemits to the `.js` file but not to the `.d.ts` file.",
+ "translation": "`.metadata.json` 文件中包含模板编译器所需的信息,这些信息来自于 `.ts` 文件中,但是没有包含在由 TypeScript 编译器生成的 `.d.ts` 文件中。\n比如,这个信息包括 TypeScript 发出的注解内容(如组件的模板),TypeScript 把它生成到了 `.js` 文件中,但是没有生成到 `.d.ts` 文件中。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This option should be set to `true` if using TypeScript's `--outFile` option, as the metadata files\nare not valid for this style of TypeScript output. It is not recommeded to use `--outFile` with\nAngular. Use a bundler, such as [webpack](https://webpack.js.org/), instead.",
+ "translation": "如果使用了 TypeScript 的 `--outFile` 选项,那就要同时设置这个选项。因为在 TypeScript 的这种输出方式下,metadata 文件是无效的。\nAngular 中不建议使用 `--outFile`,请改用 [webpack](https://webpack.js.org/) 之类的打包器代替。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This option can also be set to `true` when using factory summaries as the factory summaries\ninclude a copy of the information that is in the `.metadata.json` file.",
+ "translation": "当使用工厂汇总器(factory summary)时,这个选项也要设置为 `true`,因为工厂汇总器在自己的 `.metadata.json` 中也包含了这些信息的一个副本。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This option tells the template compiler to report an error to the `.metadata.json`\nfile if `\"skipMetadataEmit\"` is `false` . This option is `false` by default. This should only be used when `\"skipMetadataEmit\"` is `false` and `\"skipTemplateCodeGen\"` is `true`.",
+ "translation": "",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "It is intended to validate the `.metadata.json` files emitted for bundling with an `npm` package. The validation is overly strict and can emit errors for metadata that would never produce an error when used by the template compiler. You can choose to suppress the error emitted by this option for an exported symbol by including `@dynamic` in the comment documenting the symbol.",
+ "translation": "它的设计意图是要验证为打包 `npm` 而生成的 `.metadata.json` 文件。\n这种验证过于严格,在使用模板编译器时甚至可能会对那些铁定不会出错的元数据文件报告一些错误。\n你可以用 `@dynamic` 在注释中指定一些要导出的符号,来禁止对它们报告错误。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "It is valid for `.metadata.json` files to contain errors. The template compiler reports these errors\nif the metadata is used to determine the contents of an annotation. The metadata\ncollector cannot predict the symbols that are designed to use in an annotation, so it will preemptively\ninclude error nodes in the metadata for the exported symbols. The template compiler can then use the error\nnodes to report an error if these symbols are used. If the client of a library intends to use a symbol in an annotation, the template compiler will not normally report\nthis until the client uses the symbol. This option allows detecting these errors during the build phase of\nthe library and is used, for example, in producing Angular libraries themselves.",
+ "translation": "对于 `.metadata.json` 文件来说,包含错误是正常的。如果这些元数据被用来确定注解的内容,模板编译器就会报告这些错误。\n元数据收集器无法判断这些符号的设计目的是用在注解中,所以它将会自作主张,在元数据中为这些导出的符号添加错误节点。\n如果这些符号被用到了,模板编译器就会根据这些错误节点报告错误。\n如果某个库的使用者只是在注解中(而不是普通代码中)使用这些符号,模板编译器通常不会报错。\n这个选项允许在该库(比如 Angular 自身这些库)的构建和使用过程中检测这类错误。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This option tells the compiler to suppress emitting `.ngfactory.js` and `.ngstyle.js` files. When set,\nthis turns off most of the template compiler and disables reporting template diagnostics.\nThis option can be used to instruct the\ntemplate compiler to produce `.metadata.json` files for distribution with an `npm` package while\navoiding the production of `.ngfactory.js` and `.ngstyle.js` files that cannot be distributed to\n`npm`.",
+ "translation": "这个选项告诉编译器忽略从 `.ngfactory.js` 和 `.ngstyle.js` 文件中发出的错误。\n如果为 `true`,它就会关闭大多数的模板编译器,并禁止汇报模板诊断信息。\n这个选项用于指示模板编译器为通过 `npm` 包分发而生成 `.metadata.json` 文件,同时避免生成无法分发到 `npm` 的 `.ngfactory.js` 和 `.ngstyle.js` 文件。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "When set to `true`, this options tells the compiler to report an error for a parameter supplied\nwhose injection type cannot be determined. When this value option is not provided or is `false`, constructor parameters of classes marked with `@Injectable` whose type cannot be resolved will\nproduce a warning.",
+ "translation": "当设置为 `true` 时,该选项会告诉编译器为那些无法确定其类型的注入参数报告错误。\n当该值没有提供或未 `false` 时,那些带有 `@Injectable` 的类,如果其构造参数的类型无法解析,就会生成一个警告。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "*Note*: It is recommended to change this option explicitly to `true` as this option will default to `true` in the future.",
+ "translation": "*注意*:建议把该选项显式改为 `true`,因为将来这个选项的默认值会是 `true`。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "When set to `true`, this option tells the template compiler to generate a flat module\nindex of the given file name and the corresponding flat module metadata. Use this option when creating\nflat modules that are packaged similarly to `@angular/core` and `@angular/common`. When this option\nis used, the `package.json` for the library should refer\nto the generated flat module index instead of the library index file. With this\noption only one `.metadata.json` file is produced that contains all the metadata necessary\nfor symbols exported from the library index. In the generated `.ngfactory.js` files, the flat\nmodule index is used to import symbols that includes both the public API from the library index\nas well as shrowded internal symbols.",
+ "translation": "当为 `true` 时,该选项告诉模板编译器生成一个指定名字的扁平模块索引和相应的扁平模块元数据。\n当要创建像 `@angular/core` 和 `@angular/common` 这样的扁平模块包时,请使用本选项。\n当使用本选项时,库的 `package.json` 文件就会引用生成的扁平模块索引,而不是库的索引文件。\n当使用本选项时,只会生成一个 `.metadata.json` 文件,其中包含从库索引中导出的符号所需的全部元数据。\n在生成的 `.ngfactory.js` 文件中,扁平模块索会用来导入包括库的公共 API 和隐藏的内部符号在内的全部符号。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "By default the `.ts` file supplied in the `files` field is assumed to be library index.\nIf more than one `.ts` file is specified, `libraryIndex` is used to select the file to use.\nIf more than one `.ts` file is supplied without a `libraryIndex`, an error is produced. A flat module\nindex `.d.ts` and `.js` will be created with the given `flatModuleOutFile` name in the same\nlocation as the library index `.d.ts` file. For example, if a library uses\n`public_api.ts` file as the library index of the module, the `tsconfig.json` `files` field\nwould be `[\"public_api.ts\"]`. The `flatModuleOutFile` options could then be set to, for\nexample `\"index.js\"`, which produces `index.d.ts` and `index.metadata.json` files. The\nlibrary's `package.json`'s `module` field would be `\"index.js\"` and the `typings` field\nwould be `\"index.d.ts\"`.",
+ "translation": "默认情况下,`files` 字段中提供的 `.ts` 文件会被当做库索引。\n如果指定了多个 `.ts` 文件,就要用 `libraryIndex` 来选择要作为库索引的文件。\n扁平模块索引会用 `flatModuleOutFile` 中给出的名字创建 `.d.ts` 和 `.js` 文件,并放在和库索引的 `.d.ts` 文件相同的位置。\n比如,如果某个库使用 `public_api.ts` 文件作为该模块的库索引,那么 `tsconfig.json` 的 `files` 字段就应该是 `[\"public_api.ts\"]`。\n然后可以把 `flatModuleOutFile` 选项设置为 `\"index.js\"`,它就会生成 `index.d.ts` 和 `index.metadata.json` 文件。\n该库的 `package.json` 文件的 `module` 字段将会是 `\"index.js\"`,而 `typings` 字段会是 `\"index.d.ts\"`。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This option specifies the preferred module id to use for importing a flat module.\nReferences generated by the template compiler will use this module name when importing symbols\nfrom the flat module.\nThis is only meaningful when `flatModuleOutFile` is also supplied. Otherwise the compiler ignores\nthis option.",
+ "translation": "该选项指定建议的模块 ID,这个 ID 用于导入扁平模块。\n从扁平模块中导入符号时,由模板编译器生成的引用将使用这个模块名称。\n它仅在同时提供了 `flatModuleOutFile` 选项时才有意义,否则,编译器将忽略此选项。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This option tells the template compiler to generate factory files (`.ngfactory.js` and `.ngstyle.js`)\nfor `.d.ts` files with a corresponding `.metadata.json` file. This option defaults to\n`true`. When this option is `false`, factory files are generated only for `.ts` files.",
+ "translation": "这个选项告诉模板编译器也为与 `.metadata.json` 文件对应的 `.d.ts` 文件生成工厂文件(`.ngfactory.js` 和 `.ngstyle.js`)。\n这个选项默认为 `true`。当该选项为 `false` 时,只会为 `.ts` 文件生成工厂文件。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This option should be set to `false` when using factory summaries.",
+ "translation": "当使用工厂汇总器时,这个选项应该设置为 `false`。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This option tells the compiler to enable the [binding expression validation](#binding-expresion-validation)\nphase of the template compiler which uses TypeScript to validate binding expressions.",
+ "translation": "该选项告诉编译器要为模板编译器启用[绑定表达式验证](#binding-expresion-validation)阶段,它会使用 TypeScript 来验证绑定表达式。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This option is `false` by default.",
+ "translation": "该选项默认是 `false`。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "*Note*: It is recommended to set this to `true` as this option will default to `true` in the future.",
+ "translation": "*注意*:建议把它设置为 `true`,因为将来它会默认为 `true`。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This option tells the compiler to use [Tsickle](https://github.com/angular/tsickle) to annotate the emitted\nJavaScript with [JsDoc](http://usejsdoc.org/) comments needed by the\n[Closure Compiler](https://github.com/google/closure-compiler). This option defaults to `false`.",
+ "translation": "该选项告诉编译器使用 [Tsickle](https://github.com/angular/tsickle) 来为生成的 JavaScript 添加供 [Closure Compiler](https://github.com/google/closure-compiler) 使用的 [JsDoc](http://usejsdoc.org/) 注解。\n该选项默认为 `false`。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Use this option to modify how the Angular specific annotations are emitted to improve tree-shaking. Non-Angular\nannotations and decorators are unnaffected. Default is `static fields`.",
+ "translation": "使用这个选项来修改生成 Angular 特有注解的方式,以提升摇树优化(tree-shaking)的效果。它对 Angular 自身之外的注解和装饰器无效。\n默认值是 `static fields`。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This tells the compiler to print extra information while compiling templates.",
+ "translation": "它告诉编译器在编译模板时打印额外的信息。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The use of `` element was deprecated starting in Angular 4.0 in favor of using\n`` to avoid colliding with the DOM's element of the same name. Setting this option to\n`true` enables the use of the deprecated `` element . This option\nis `false` by default. This option might be required by some third-party Angular libraries.",
+ "translation": "从 Angular 4.0 开始,`` 元素已经被废弃了,要改用 `` 以避免和同名 DOM 元素的冲突。把该选项设置为 `true` 将会允许使用已废弃的 `` 元素。\n该选项默认为 `false`。某些第三方 Angular 库可能会需要该选项。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The Angular template compiler transforms code that is used, or could be used, in an annotation\nto allow it to be imported from template factory modules. See\n[metadata rewriting](#metadata-rewriting) for more information.",
+ "translation": "Angular 的模板编译器会转换注解中使用或可能使用的代码,以便能从模板的工厂模块中导入它。\n参见[元数据重写](#metadata-rewriting)以了解更多信息。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Setting this option to `false` disables this rewriting, requiring the rewriting to be\ndone manually.",
+ "translation": "把该选项设置为 `false` 将会禁止这种重写,如果需要重写就去得人工完成了。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This option tells the compiler whether to remove blank text nodes from compiled templates.\nAs of v6, this option is `false` by default, which results in smaller emitted template factory modules.",
+ "translation": "该选项会告诉编译器是否要从编译后的模板中移除空白的文本节点。\n对于 Angular v6,该选项默认为 `false`,它会移除空白节点,以生成更小的模板工厂模块。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Tells the compiler to generate all the possible generated files even if they are empty. This option is\n`false` by default. This is an option used by `bazel` build rules and is needed to simplify\nhow `bazel` rules track file dependencies. It is not recommended to use this option outside of the `bazel`\nrules.",
+ "translation": "告诉编译器生成所有可能生成的文件 —— 即使是空文件。\n该选项默认为 `false`。\n这是供 `bazel` 构建规则使用的选项,它用于简化 `bazel` 规则跟踪文件依赖的方式。\n除了 `bazel` 规则之外不建议使用该选项。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Tells the compiler to generate definitions using the Render3 style code generation. This option defaults to `false`.",
+ "translation": "告诉编译器使用 Render3 风格的代码生成器来来生成各种定义。\n该选项默认为 `false`。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Not all features are supported with this option enabled. It is only supported\nfor experimentation and testing of Render3 style code generation.",
+ "translation": "当开启该选项时,有些特性不受支持。它仅仅用来为试验和测试 Render3 风格的代码生成提供支持。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "*Note*: Is it not recommended to use this option as it is not yet feature complete with the Render2 code generation.",
+ "translation": "*注意*:不建议使用该选项,因为它在使用 Render2 的代码生成器时还缺少一些特性。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
@@ -1401,7 +1596,7 @@
},
{
"original": "You specify the metadata with **decorators** such as `@Component()` and `@Input()`.\nYou also specify metadata implicitly in the constructor declarations of these decorated classes.",
- "translation": "我们通过**装饰器**来指定元数据,比如 `@Component()` 和 `@Input()`。\n我们还可以在这些带装饰器的类的构造函数中隐式指定元数据。",
+ "translation": "你通过**装饰器**来指定元数据,比如 `@Component()` 和 `@Input()`。\n你还可以在这些带装饰器的类的构造函数中隐式指定元数据。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
@@ -1410,7 +1605,7 @@
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
- "original": "The Angular compiler extracts the metadata _once_ and generates a _factory_ for `TypicalComponent`.\nWhen it needs to create a `TypicalComponent` instance, Angular calls the factory, which produces a new visual element, bound to a new instance of the component class with its injected dependency.",
+ "original": "The Anglar compiler extracts the metadata _once_ and generates a _factory_ for `TypicalComponent`.\nWhen it needs to create a `TypicalComponent` instance, Angular calls the factory, which produces a new visual element, bound to a new instance of the component class with its injected dependency.",
"translation": "Angular 编译器只提取**一次**元数据,并且为 `TypicalComponent` 生成一个**工厂**。\n当它需要创建 `TypicalComponent` 的实例时,Angular 调用这个工厂,工厂会生成一个新的可视元素,并且把它(及其依赖)绑定到组件类的一个新实例上。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
@@ -1421,7 +1616,7 @@
},
{
"original": "You write metadata in a _subset_ of TypeScript that must conform to the following general constraints:",
- "translation": "我们只能使用 TypeScript 的一个**子集**书写元数据,它必须满足下列限制:",
+ "translation": "你只能使用 TypeScript 的一个**子集**书写元数据,它必须满足下列限制:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
@@ -1446,7 +1641,7 @@
},
{
"original": "The next sections elaborate on these points.",
- "translation": "我们将在下一节详细解释这些问题。",
+ "translation": "下一节将会详细解释这些问题。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
@@ -1456,12 +1651,12 @@
},
{
"original": "It helps to think of the AOT compiler as having two phases: a code analysis phase in which it simply records a representation of the source; and a code generation phase in which the compiler's `StaticReflector` handles the interpretation as well as places restrictions on what it interprets.",
- "translation": "我们可以把 AOT 编译器看做两个阶段:在代码分析阶段,它只记录源代码,而在代码生成阶段,编译器的`StaticReflector`会解释这些结果,并为这些结果加上限制。",
+ "translation": "可以把 AOT 编译器看做两个阶段:在代码分析阶段,它只记录源代码,而在代码生成阶段,编译器的 `StaticReflector` 会解释这些结果,并为这些结果加上限制。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
"original": "## Phase 1: analysis",
- "translation": "## 阶段1:分析",
+ "translation": "## 阶段 1:分析",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
@@ -1471,12 +1666,12 @@
},
{
"original": "At the same time, the AOT **_collector_** analyzes the metadata recorded in the Angular decorators and outputs metadata information in **`.metadata.json`** files, one per `.d.ts` file.",
- "translation": "同时,AOT **收集器(collector)** 会记录 Angular 装饰器中的元数据,并把它们输出到**`.metadata.json`**文件中,和每个`.d.ts`文件相对应。",
+ "translation": "同时,AOT **收集器(collector)** 会记录 Angular 装饰器中的元数据,并把它们输出到**`.metadata.json`**文件中,和每个 `.d.ts` 文件相对应。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
"original": "You can think of `.metadata.json` as a diagram of the overall structure of a decorator's metadata, represented as an [abstract syntax tree (AST)](https://en.wikipedia.org/wiki/Abstract_syntax_tree).",
- "translation": "我们可以把`.metadata.json`文件看做一个包括全部装饰器的元数据的全景图,就像[抽象语法树 (AST) ](https://en.wikipedia.org/wiki/Abstract_syntax_tree)一样。",
+ "translation": "你可以把 `.metadata.json` 文件看做一个包括全部装饰器的元数据的全景图,就像[抽象语法树 (AST) ](https://en.wikipedia.org/wiki/Abstract_syntax_tree)一样。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
@@ -1484,6 +1679,11 @@
"translation": "Angular 的 [schema.ts](https://github.com/angular/angular/blob/master/packages/compiler-cli/src/metadata/schema.ts) 把这个 JSON 格式表示成了一组 TypeScript 接口。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
+ {
+ "original": "### Expression syntax",
+ "translation": "### 表达式语法",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
{
"original": "The _collector_ only understands a subset of JavaScript.\nDefine metadata objects with the following limited syntax:",
"translation": "这个**收集器**只能理解 JavaScript 的一个子集。\n请使用下列受限语法定义元数据对象:",
@@ -1491,12 +1691,12 @@
},
{
"original": "If an expression uses unsupported syntax, the _collector_ writes an error node to the `.metadata.json` file. The compiler later reports the error if it needs that\npiece of metadata to generate the application code.",
- "translation": "如果表达式使用了不支持的语法,**收集器**就会往`.metadata.json`文件中写入一个错误节点。稍后,如果编译器用到元数据中的这部分内容来生成应用代码,它就会报告这个错误。",
+ "translation": "如果表达式使用了不支持的语法,**收集器**就会往 `.metadata.json` 文件中写入一个错误节点。稍后,如果编译器用到元数据中的这部分内容来生成应用代码,它就会报告这个错误。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
"original": "If you want `ngc` to report syntax errors immediately rather than produce a `.metadata.json` file with errors, set the `strictMetadataEmit` option in `tsconfig`.",
- "translation": "如果你希望`ngc`立即汇报这些语法错误,而不要生成带有错误信息的`.metadata.json`文件,可以到`tsconfig`中设置 `strictMetadataEmit` 选项。",
+ "translation": "如果你希望 `ngc` 立即汇报这些语法错误,而不要生成带有错误信息的 `.metadata.json` 文件,可以到 `tsconfig` 中设置 `strictMetadataEmit` 选项。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
{
@@ -1504,11 +1704,756 @@
"translation": "Angular 库通过这个选项来确保所有的 `.metadata.json` 文件都是干净的。当你要构建自己的代码库时,这也同样是一项最佳实践。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
+ {
+ "original": "### No arrow functions",
+ "translation": "### 不要有箭头函数",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The AOT compiler does not support [function expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function)\nand [arrow functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions), also called _lambda_ functions.",
+ "translation": "AOT 编译器不支持 [函数表达式](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function)\n和 [箭头函数](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions)(也叫 *Lambda* 函数)。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Consider the following component decorator:",
+ "translation": "考虑如下组件装饰器:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The AOT _collector_ does not support the arrow function, `() => new Server()`, in a metadata expression.\nIt generates an error node in place of the function.",
+ "translation": "AOT 的*收集器*不支持在元数据表达式中出现箭头函数 `() => new Server()`。\n它会在该函数中就地生成一个错误节点。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "When the compiler later interprets this node, it reports an error that invites you to turn the arrow function into an _exported function_.",
+ "translation": "稍后,当编译器解释该节点时,它就会报告一个错误,让你把这个箭头函数转换成一个*导出的函数*。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "You can fix the error by converting to this:",
+ "translation": "你可以把它改写成这样来修复这个错误:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Beginning in version 5, the compiler automatically performs this rewritting while emitting the `.js` file.",
+ "translation": "从 Angular v5 开始,编译器会在生成 `.js` 文件时自动执行这种改写。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "### Limited function calls",
+ "translation": "### 受限函数调用",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The _collector_ can represent a function call or object creation with `new` as long as the syntax is valid. The _collector_ only cares about proper syntax.",
+ "translation": "只要语法有效,*收集器*就可以支持函数调用或使用 `new` 来创建对象。*收集器*只在乎语法是否正确。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "But beware. The compiler may later refuse to generate a call to a _particular_ function or creation of a _particular_ object.\nThe compiler only supports calls to a small set of functions and will use `new` for only a few designated classes. These functions and classes are in a table of [below](#supported-functions).",
+ "translation": "但要注意。编译器稍后可能拒绝调用*特定的*函数或拒绝创建*特定的*对象。\n编译器值仅支持调用一小部分函数,也只能 `new` 一小部分类。这些函数和类列在了[后面](#supported-functions)的表格中。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "### Folding",
+ "translation": "### 折叠(fold)",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler can only resolve references to **_exported_** symbols.\nFortunately, the _collector_ enables limited use of non-exported symbols through _folding_.",
+ "translation": "编译器只能解析对***导出***的符号的引用。\n幸运的是,*收集器*支持通过*折叠*来有限的使用那些未导出的符号。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The _collector_ may be able to evaluate an expression during collection and record the result in the `.metadata.json` instead of the original expression.",
+ "translation": "*收集器*可以在收集期间执行表达式,并用其结果代替原始表达式,记录到 `.metadata.json` 中。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "For example, the _collector_ can evaluate the expression `1 + 2 + 3 + 4` and replace it with the result, `10`.",
+ "translation": "比如,*收集器*可以执行表达式 `1 + 2 + 3 + 4`,并使用它的结果 `10` 替换它。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This process is called _folding_. An expression that can be reduced in this manner is _foldable_.",
+ "translation": "这个过程被称为*折叠*。能用这种方式进行简化的表达式就是*可折叠的*。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The collector can evaluate references to\nmodule-local `const` declarations and initialized `var` and `let` declarations, effectively removing them from the `.metadata.json` file.",
+ "translation": "收集器可以计算对模块局部变量的 `const` 声明和初始化过的 `var` 和 `let` 声明,并从 `.metadata.json` 文件中移除它们。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Consider the following component definition:",
+ "translation": "考虑下列组件定义:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler could not refer to the `template` constant because it isn't exported.",
+ "translation": "编译器不能引用 `template` 常量,因为它是未导出的。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "But the _collector_ can _fold_ the `template` constant into the metadata definition by inlining its contents.\nThe effect is the same as if you had written:",
+ "translation": "但是*折叠器*可以通过内联 `template` 常量的方式把它*折叠*进元数据定义中。\n最终的结果和你以前的写法是一样的:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "There is no longer a reference to `template` and, therefore, nothing to trouble the compiler when it later interprets the _collector's_ output in `.metadata.json`.",
+ "translation": "这里没有对 `template` 的引用,因此,当编译器稍后对位于 `.metadata.json` 中的*收集器*输出进行解释时,不会再出问题。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "You can take this example a step further by including the `template` constant in another expression:",
+ "translation": "你还可以通过把 `template` 常量包含在其它表达式中来让这个例子深入一点:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The _collector_ reduces this expression to its equivalent _folded_ string:",
+ "translation": "*收集器*把该表达式缩减成其等价的*已折叠*字符串:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "#### Foldable syntax",
+ "translation": "#### 可折叠的语法",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The following table describes which expressions the _collector_ can and cannot fold:",
+ "translation": "下表中描述了哪些表达式是否能被*收集器*折叠:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "If an expression is not foldable, the collector writes it to `.metadata.json` as an [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) for the compiler to resolve.",
+ "translation": "如果表达式是不可折叠的,那么收集器就会把它作为一个 [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree)(抽象语法树) 写入 `.metadata.json` 中,留给编译器去解析。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "## Phase 2: code generation",
+ "translation": "## 阶段 2:代码生成",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The _collector_ makes no attempt to understand the metadata that it collects and outputs to `.metadata.json`. It represents the metadata as best it can and records errors when it detects a metadata syntax violation.",
+ "translation": "*收集器*不会试图理解它收集并输出到 `.metadata.json` 中的元数据,它所能做的只是尽可能准确的表述这些元数据,并在检测到元数据中的语法违规时记录这些错误。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "It's the compiler's job to interpret the `.metadata.json` in the code generation phase.",
+ "translation": "解释这些 `.metadata.json` 是编译器在代码生成阶段要承担的工作。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler understands all syntax forms that the _collector_ supports, but it may reject _syntactically_ correct metadata if the _semantics_ violate compiler rules.",
+ "translation": "编译器理解*收集器*支持的所有语法形式,但是它也可能拒绝那些虽然*语法正确*但*语义*违反了编译器规则的元数据。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler can only reference _exported symbols_.",
+ "translation": "编译器只能引用*已导出的符号*。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Decorated component class members must be public. You cannot make an `@Input()` property private or internal.",
+ "translation": "带有装饰器的类成员必须是公开的。你不可能制作一个私有或内部使用的 `@Input()` 属性。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Data bound properties must also be public.",
+ "translation": "数据绑定的属性同样必须是公开的。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Most importantly, the compiler only generates code to create instances of certain classes, support certain decorators, and call certain functions from the following lists.",
+ "translation": "最重要的是,编译器生成代码时,只支持为下面列出的某些类创建实例、只支持某些装饰器、只会调用某些函数。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "### New instances",
+ "translation": "### 新建实例",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler only allows metadata that create instances of the class `InjectionToken` from `@angular/core`.",
+ "translation": "编译器只允许创建来自 `@angular/core` 的 `InjectionToken` 类创建实例。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "### Annotations/Decorators",
+ "translation": "### 注解 / 装饰器",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler only supports metadata for these Angular decorators.",
+ "translation": "编译器只支持下列 Angular 装饰器的元数据。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "### Macro-functions and macro-static methods",
+ "translation": "### 宏函数或静态宏函数",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler also supports _macros_ in the form of functions or static\nmethods that return an expression.",
+ "translation": "编译器也支持在返回表达式的函数或静态函数中使用*宏*。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "For example, consider the following function:",
+ "translation": "考虑下面的函数:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "You can call the `wrapInArray` in a metadata definition because it returns the value of an expression that conforms to the compiler's restrictive JavaScript subset.",
+ "translation": "你可以在元数据定义中调用 `wrapInArray`,因为它所返回的表达式的值满足编译器支持的 JavaScript 受限子集。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "You might use `wrapInArray()` like this:",
+ "translation": "你还可以这样使用 `wrapInArray()`:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler treats this usage as if you had written:",
+ "translation": "编译器会把这种用法处理成你以前的写法:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The collector is simplistic in its determination of what qualifies as a macro\nfunction; it can only contain a single `return` statement.",
+ "translation": "收集器决定哪些函数是宏函数是很简单的 —— 它只能包含一个 `return` 语句。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The Angular [`RouterModule`](api/router/RouterModule) exports two macro static methods, `forRoot` and `forChild`, to help declare root and child routes.\nReview the [source code](https://github.com/angular/angular/blob/master/packages/router/src/router_module.ts#L139 \"RouterModule.forRoot source code\")\nfor these methods to see how macros can simplify configuration of complex [NgModules](guide/ngmodules).",
+ "translation": "Angular 的 [`RouterModule`](api/router/RouterModule) 导出了两个静态宏函数 `forRoot` 和 `forChild`,以帮助声明根路由和子路由。\n查看这些方法的[源码](https://github.com/angular/angular/blob/master/packages/router/src/router_module.ts#L139 \"RouterModule.forRoot source code\"),以了解宏函数是如何简化复杂的 [NgModule](guide/ngmodules) 配置的。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "### Metadata rewriting",
+ "translation": "### 元数据重写",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler treats object literals containing the fields `useClass`, `useValue`, `useFactory`, and `data` specially. The compiler converts the expression initializing one of these fields into an exported variable, which replaces the expression. This process of rewriting these expressions removes all the restrictions on what can be in them because\nthe compiler doesn't need to know the expression's value—it just needs to be able to generate a reference to the value.",
+ "translation": "编译器会对含有 `useClass`、`useValue`、`useFactory` 和 `data` 的对象字面量进行特殊处理。\n编译器会把用这些字段之一初始化的表达式转换成一个导出为一个变量,并用它替换该表达式。\n这个重写表达式的过程,会消除它们受到的所有限制,因为编译器并不需要知道该表达式的值,它只要能生成对该值的引用就行了。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "You might write something like:",
+ "translation": "你可以这样写:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Without rewriting, this would be invalid because lambdas are not supported and `TypicalServer` is not exported.",
+ "translation": "如果不重写,这就是无效的,因为这里不支持 Lambda 表达式,而且 `TypicalServer` 也没有被导出。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "To allow this, the compiler automatically rewrites this to something like:",
+ "translation": "为了允许这种写法,编译器自动把它重写成了这样:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This allows the compiler to generate a reference to `ɵ0` in the\nfactory without having to know what the value of `ɵ0` contains.",
+ "translation": "这就让编译器能在工厂中生成一个对 `ɵ0` 的引用,而不用知道 `ɵ0` 中包含的值到底是什么。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler does the rewriting during the emit of the `.js` file. This doesn't rewrite the `.d.ts` file, however, so TypeScript doesn't recognize it as being an export. Thus, it does not pollute the ES module's exported API.",
+ "translation": "编译器会在生成 `.js` 文件期间进行这种重写。它不会重写 `.d.ts` 文件,所以 TypeScript 也不会把这个变量当做一项导出,因此也就不会污染 ES 模块中导出的 API。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "## Metadata Errors",
+ "translation": "## 元数据错误",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The following are metadata errors you may encounter, with explanations and suggested corrections.",
+ "translation": "你可能遇到一些元数据错误,下面是对它们的解释和纠正建议。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "
Expression form not supported
",
+ "translation": "
不支持这种表达式格式
",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler encountered an expression it didn't understand while evalutating Angular metadata.",
+ "translation": "编译器在对 Angular 元数据求值时遇到了一个它不能理解的表达式。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Language features outside of the compiler's [restricted expression syntax](#expression-syntax)\ncan produce this error, as seen in the following example:",
+ "translation": "除编译器[允许的表达式语法](#expression-syntax)之外的语言特性可能导致这个错误,比如下面的例子:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "You can use `typeof` and bracket notation in normal application code.\nYou just can't use those features within expressions that define Angular metadata.",
+ "translation": "你可以在普通的应用代码中使用 `typeof` 和方括号标记法来指定属性名,但是这些特性不能在定义 Angular 元数据的表达式中使用。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Avoid this error by sticking to the compiler's [restricted expression syntax](#expression-syntax)\nwhen writing Angular metadata\nand be wary of new or unusual TypeScript features.",
+ "translation": "在写 Angular 的元数据时,严格遵循编译器的[受限表达式语法](#expression-syntax)可以避免这个错误,此外还要小心那些新的或罕见的 TypeScript 特性。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "
Reference to a local (non-exported) symbol
",
+ "translation": "
引用了局部(未导出的)符号
",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler encountered a referenced to a locally defined symbol that either wasn't exported or wasn't initialized.",
+ "translation": "编译器遇到了局部定义的未导出或未初始化的符号。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Here's a `provider` example of the problem.",
+ "translation": "下面就是存在该问题的 `provider` 范例。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler generates the component factory, which includes the `useValue` provider code, in a separate module. _That_ factory module can't reach back to _this_ source module to access the local (non-exported) `foo` variable.",
+ "translation": "编译器会在单独的模块中生成这个 `userValue` 提供商的代码。*那个*工厂模块不能访问*这个*源码模块,无法访问这个(未导出的)`foo` 变量。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "You could fix the problem by initializing `foo`.",
+ "translation": "你可以通过初始化 `foo` 来修正这个错误。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler will [fold](#folding) the expression into the provider as if you had written this.",
+ "translation": "编译器将会把这个表达式[折叠](#folding)进 `providers` 中,就像你以前的写法一样。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Alternatively, you can fix it by exporting `foo` with the expectation that `foo` will be assigned at runtime when you actually know its value.",
+ "translation": "另外,你也可以通过导出 `foo` 来解决它,这样 `foo` 将会在运行期间你真正知道它的值的时候被赋值。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Adding `export` often works for variables referenced in metadata such as `providers` and `animations` because the compiler can generate _references_ to the exported variables in these expressions. It doesn't need the _values_ of those variables.",
+ "translation": "添加 `export` 的方式通常用于需要在元数据中引用变量时,如 `providers` 和 `animations`,这样编译器就可以在这些表达式中生成对已导出变量的引用了。它不需要知道这些变量的*值*。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Adding `export` doesn't work when the compiler needs the _actual value_\nin order to generate code.\nFor example, it doesn't work for the `template` property.",
+ "translation": "当编译器需要知道*真正的值*已生成代码时,添加 `export` 的方式就是无效的。比如这里的 `template` 属性。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler needs the value of the `template` property _right now_ to generate the component factory.\nThe variable reference alone is insufficient.\nPrefixing the declaration with `export` merely produces a new error, \"[`Only initialized variables and constants can be referenced`](#only-initialized-variables)\".",
+ "translation": "编译器*现在就*需要 `template` 属性的值来生成组件工厂。\n仅仅有对该变量的引用是不够的。\n给这个声明加上 `export` 前缀只会生成一个新的错误 \"[`Only initialized variables and constants can be referenced`【只能引用初始化过的变量和常量】](#only-initialized-variables)\"。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "
Only initialized variables and constants
",
+ "translation": "
只允许使用初始化过的变量和常量
",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler found a reference to an exported variable or static field that wasn't initialized.\nIt needs the value of that variable to generate code.",
+ "translation": "编译器发现某个到已导出的变量或静态字段的引用是没有初始化过的。而它需要根据那个变量的值来生成代码。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The following example tries to set the component's `template` property to the value of\nthe exported `someTemplate` variable which is declared but _unassigned_.",
+ "translation": "下面的例子试图把组件的 ` template` 属性设置为已导出的 `someTemplate` 变量的值,而这个值虽然声明过,却没有初始化过。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "You'd also get this error if you imported `someTemplate` from some other module and neglected to initialize it there.",
+ "translation": "如果你从其它模块中导入了 `someTemplate`,但那个模块中忘了初始化它,就会看到这个错误。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler cannot wait until runtime to get the template information.\nIt must statically derive the value of the `someTemplate` variable from the source code\nso that it can generate the component factory, which includes\ninstructions for building the element based on the template.",
+ "translation": "编译器不能等到运行时才得到该模板的信息。\n它必须从源码中静态获得这个 `someTemplate` 变量的值,以便生成组件工厂,组件工厂中需要包含根据这个模板来生成元素的代码。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "To correct this error, provide the initial value of the variable in an initializer clause _on the same line_.",
+ "translation": "要纠正这个错误,请在*同一行*的初始化子句中初始化这个变量的值。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "
Reference to a non-exported class
",
+ "translation": "
引用了未导出的类
",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Metadata referenced a class that wasn't exported.",
+ "translation": "元数据引用了一个未导出的类。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "For example, you may have defined a class and used it as an injection token in a providers array\nbut neglected to export that class.",
+ "translation": "比如,你可能定义了一个类并在某个 `providers` 数组中把它用作了依赖注入令牌,但是忘了导出这个类。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Angular generates a class factory in a separate module and that\nfactory [can only access exported classes](#exported-symbols).\nTo correct this error, export the referenced class.",
+ "translation": "Angular 会在一个单独的模块中生成类工厂,而那个工厂[只能访问已导出的类](#exported-symbols)。\n要纠正这个问题,就要导出所引用的类。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "
Reference to a non-exported function
",
+ "translation": "
引用了未导出的函数
",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Metadata referenced a function that wasn't exported.",
+ "translation": "元数据中引用了未导出的函数。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "For example, you may have set a providers `useFactory` property to a locally defined function that you neglected to export.",
+ "translation": "比如,你可能已经把某个服务提供商的 `useFactory` 属性设置成了一个局部定义但忘了导出的函数。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Angular generates a class factory in a separate module and that\nfactory [can only access exported functions](#exported-symbols).\nTo correct this error, export the function.",
+ "translation": "Angular 会在一个单独的模块中生成类工厂,那个工厂[只能访问已导出的函数](#exported-symbols)。\n要纠正这个错误,请导出该函数。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "
Function calls are not supported
",
+ "translation": "
不支持函数调用
",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler does not currently support [function expressions or lambda functions](#function-expression).\nFor example, you cannot set a provider's `useFactory` to an anonymous function or arrow function like this.",
+ "translation": "编译器目前不支持[函数表达式或 Lambda 表达式](#function-expression)。\n比如,你不能把某个服务提供商的 `useFactory` 设置成如下匿名函数或函数表达式。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "You also get this error if you call a function or method in a provider's `useValue`.",
+ "translation": "如果你在某个提供商的 `useValue` 中调用函数或方法,也会导致这个错误。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "To correct this error, export a function from the module and refer to the function in a `useFactory` provider instead.",
+ "translation": "要改正这个问题,就要从模块中导出这个函数,并改成在服务提供商的 `useFactory` 中引用该函数。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "
Destructured variable or constant not supported
",
+ "translation": "
不支持解构变量或常量
",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler does not support references to variables assigned by [destructuring](https://www.typescriptlang.org/docs/handbook/variable-declarations.html#destructuring).",
+ "translation": "编译器不支持引用通过[解构](https://www.typescriptlang.org/docs/handbook/variable-declarations.html#destructuring)赋值的方式得到的变量。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "For example, you cannot write something like this:",
+ "translation": "比如,你不能这么写:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "To correct this error, refer to non-destructured values.",
+ "translation": "要纠正这个错误,就要引用非解构方式的变量。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "
Could not resolve type
",
+ "translation": "
不能解析类型
",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler encountered a type and can't determine which module exports that type.",
+ "translation": "编译器遇到了某个类型,但是不知道它是由哪个模块导出的。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This can happen if you refer to an ambient type.\nFor example, the `Window` type is an ambiant type declared in the global `.d.ts` file.",
+ "translation": "这通常会发生在你引用环境类型时。\n比如,`Window` 类型就是在全局 `.d.ts` 文件中声明的环境类型。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "You'll get an error if you reference it in the component constructor,\nwhich the compiler must statically analyze.",
+ "translation": "如果你在组件的构造函数中引用它就会导致一个错误,因为编译器必须对构造函数进行静态分析。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "TypeScript understands ambiant types so you don't import them.\nThe Angular compiler does not understand a type that you neglect to export or import.",
+ "translation": "TypeScript 能理解这些环境类型,所以你不用导入它们。\n但 Angular 编译器不理解你没有导入或导出过的类型。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "In this case, the compiler doesn't understand how to inject something with the `Window` token.",
+ "translation": "这种情况下,编译器就无法理解如何使用这个 `Window` 令牌来进行注入。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Do not refer to ambient types in metadata expressions.",
+ "translation": "不要在元数据表达式中引用环境类型。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "If you must inject an instance of an ambiant type,\nyou can finesse the problem in four steps:",
+ "translation": "如果你必须注入某个环境类型的实例,可以用以下四步来巧妙解决这个问题:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "1. Create an injection token for an instance of the ambiant type.",
+ "translation": "为环境类型的实例创建一个注入令牌。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "1. Create a factory function that returns that instance.",
+ "translation": "创建一个返回该实例的工厂函数。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "1. Add a `useFactory` provider with that factory function.",
+ "translation": "使用该工厂函数添加一个 `useFactory` 提供商。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "1. Use `@Inject` to inject the instance.",
+ "translation": "使用 `@Inject` 来注入这个实例。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Here's an illustrative example.",
+ "translation": "下面的例子说明了这一点。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The `Window` type in the constructor is no longer a problem for the compiler because it\nuses the `@Inject(WINDOW)` to generate the injection code.",
+ "translation": "对于编译器来说,构造函数中出现 `Window` 类型已不再是个问题,因为它现在使用 `@Inject(WINDOW)` 来生成注入代码。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Angular does something similar with the `DOCUMENT` token so you can inject the browser's `document` object (or an abstraction of it, depending upon the platform in which the application runs).",
+ "translation": "Angular 也用 `DOCUMENT` 令牌做了类似的事情,所以你也可以注入浏览器的 `document` 对象(或它的一个抽象层,取决于该应用运行在哪个平台)。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "
Name expected
",
+ "translation": "
期待是名字
",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler expected a name in an expression it was evaluating.\nThis can happen if you use a number as a property name as in the following example.",
+ "translation": "编译器期待它正在求值的表达式中是一个名字。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Change the name of the property to something non-numeric.",
+ "translation": "把该属性的名字改为非数字类型。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "
Unsupported enum member name
",
+ "translation": "
不支持的枚举成员名
",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Angular couldn't determine the value of the [enum member](https://www.typescriptlang.org/docs/handbook/enums.html)\nthat you referenced in metadata.",
+ "translation": "Angular 不能确定你在元数据中引用的[枚举成员](https://www.typescriptlang.org/docs/handbook/enums.html)的值。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler can understand simple enum values but not complex values such as those derived from computed properties.",
+ "translation": "编译器可以理解简单的枚举值,但不能理解复杂的,比如从那些计算属性中派生出来的。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Avoid referring to enums with complicated initializers or computed properties.",
+ "translation": "避免引用那些使用了复杂初始化对象或计算属性的枚举。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "
Tagged template expressions are not supported
",
+ "translation": "
不支持带标签函数的模板表达式
",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler encountered a JavaScript ES2015 [tagged template expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals) such as,",
+ "translation": "当编译器遇到这样的[带标签函数的模板表达式](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals) 时:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "[`String.raw()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)\nis a _tag function_ native to JavaScript ES2015.",
+ "translation": "[`String.raw()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw) 是一个 ES2015 原生的*标签函数*。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The AOT compiler does not support tagged template expressions; avoid them in metadata expressions.",
+ "translation": "AOT 编译器不支持带标签函数的模板表达式,避免在元数据表达式中使用它们。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "
Symbol reference expected
",
+ "translation": "
期待是符号引用
",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The compiler expected a reference to a symbol at the location specified in the error message.",
+ "translation": "编译器期待在错误信息指出的位置是一个符号引用。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This error can occur if you use an expression in the `extends` clause of a class.",
+ "translation": "当你在类的 `extends` 子句中使用表达式时就会出现这个错误。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "## Phase 3: binding expression validation",
+ "translation": "## 阶段 3:验证绑定表达式",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "In the validation phase, the Angular template compiler uses the TypeScript compiler to validate the\n binding expressions in templates. Enable this phase explicity by adding the compiler\n option `\"fullTemplateTypeCheck\"` in the `\"angularCompilerOptions\"` of the project's `tsconfig.json` (see\n [Angular Compiler Options](#compiler-options)).",
+ "translation": "在验证阶段,Angular 的模板编译器会使用 TypeScript 编译器来验证模板中的绑定表达式。\n 通过在项目的 `tsconfig.json`(参见 [Angular Compiler Options](#compiler-options))的 `\"angularCompilerOptions\"` 中添加编译选项 `\"fullTemplateTypeCheck\"` 可以启用这个阶段。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Template validation produces error messages when a type error is detected in a template binding\n expression, similar to how type errors are reported by the TypeScript compiler against code in a `.ts`\n file.",
+ "translation": "当模板绑定表达式中检测到类型错误时,进行模板验证时就会生成错误。这和 TypeScript 编译器在处理 `.ts` 文件中的代码时报告错误很相似。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "For example, consider the following component:",
+ "translation": "比如,考虑下列组件:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This will produce the following error:",
+ "translation": "这会生成如下错误:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The file name reported in the error message, `my.component.ts.MyComponent.html`, is a synthetic file\n generated by the template compiler that holds contents of the `MyComponent` class template.\n Compiler never writes this file to disk. The line and column numbers are relative to the template string\n in the `@Component` annotation of the class, `MyComponent` in this case. If a component uses\n `templateUrl` instead of `template`, the errors are reported in the HTML file refereneced by the\n `templateUrl` instead of a synthetic file.",
+ "translation": "错误信息中汇报的文件名 `my.component.ts.MyComponent.html` 是一个由模板编译器生成出的虚拟文件,\n 用于保存 `MyComponent` 类的模板内容。\n 编译器永远不会把这个文件写入磁盘。这个例子中,这里的行号和列号都是相对于 `MyComponent` 的 `@Component` 注解中的模板字符串的。\n 如果组件使用 `templateUrl` 来代替 `template`,这些错误就会在 `templateUrl` 引用的 HTML 文件中汇报,而不是这个虚拟文件中。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The error location is the beginning of the text node that contains the interpolation expression with\n the error. If the error is in an attribute binding such as `[value]=\"person.address.street\"`, the error\n location is the location of the attribute that contains the error.",
+ "translation": "错误的位置是从包含出错的插值表达式的那个文本节点开始的。\n 如果错误是一个属性绑定,比如 `[value]=\"person.address.street\"` ,错误的位置就是那个包含错误的属性的位置。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The validation uses the TypeScript type checker and the options supplied to the TypeScript compiler to control\n how detailed the type validation is. For example, if the `strictTypeChecks` is specified, the error ```my.component.ts.MyComponent.html(1,1): : Object is possibly 'undefined'``` is reported as well as the above error message.",
+ "translation": "这个验证过程使用 TypeScript 的类型检查器,这些选项也会提供给 TypeScript 编译器以控制类型验证的详细程度。\n 比如,如果指定了 `strictTypeChecks`,就会像上面的错误信息一样报告 ```my.component.ts.MyComponent.html(1,1): : Object is possibly 'undefined'``` 错误。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "### Type narrowing",
+ "translation": "### 类型窄化",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The expression used in an `ngIf` directive is used to narrow type unions in the Angular\n template compiler, the same way the `if` expression does in TypeScript. For example, to avoid\n `Object is possibly 'undefined'` error in the template above, modify it to only emit the\n interpolation if the value of `person` is initialized as shown below:",
+ "translation": "在 `ngIf` 指令中使用的表达式用来在 Angular 模板编译器中窄化联合类型,就像 TypeScript 中的 `if` 表达式一样。\n 比如,要在上述模板中消除 `Object is possibly 'undefined'` 错误,可以把它改成只在 `person` 的值初始化过的时候才生成这个插值表达式。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Using `*ngIf` allows the TypeScript compiler to infer that the `person` used in the\n binding expression will never be `undefined`.",
+ "translation": "使用 `*ngIf` 能让 TypeScript 编译器推断出这个绑定表达式中使用的 `person` 永远不会是 `undefined`。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "#### Custom `ngIf` like directives",
+ "translation": "#### 类似于的 `ngIf` 的自定义指令",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Directives that behave like `*ngIf` can declare that they want the same treatment by including\n a static member marker that is a signal to the template compiler to treat them\n like `*ngIf`. This static member for `*ngIf` is:",
+ "translation": "那些行为与 `*ngIf` 类似的指令可以通过包含一个静态成员作为标记,来告诉模板编译器它们希望和 `*ngIf` 享受同等待遇。这个 `*ngIf` 的静态成员就是:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "This declares that the input property `ngIf` of the `NgIf` directive should be treated as a\n guard to the use of its template, implying that the template will only be instantiated if\n the `ngIf` input property is true.",
+ "translation": "它声明了 `NgIf` 指令的 `ngIf` 属性应该在用到它的模板中看做一个守卫,以表明只有当 `ngIf` 这个输入属性为 `true` 时,才应该生成那个模板。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "### Non-null type assertion operator",
+ "translation": "### 非空类型断言操作符",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Use the [non-null type assertion operator](guide/template-syntax#non-null-assertion-operator)\n to suppress the `Object is possibly 'undefined'` error when it is incovienent to use\n `*ngIf` or when some constraint in the component ensures that the expression is always\n non-null when the binding expression is interpolated.",
+ "translation": "使用 [非空类型断言操作符](guide/template-syntax#non-null-assertion-operator)可以在不方便使用 `*ngIf` 或\n 当组件中的某些约束可以确保这个绑定表达式在求值时永远不会为空时,防止出现 `Object is possibly 'undefined'` 错误。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "In the following example, the `person` and `address` properties are always set together,\n implying that `address` is always non-null if `person` is non-null. There is no convenient\n way to describe this constraint to TypeScript and the template compiler, but the error\n is suppressed in the example by using `address!.street`.",
+ "translation": "在下列例子中,`person` 和 `address` 属性总是一起出现的,如果 `person` 非空,则 `address` 也一定非空。没有一种简便的写法可以向 TypeScript 和模板编译器描述这种约束。但是这个例子中使用 `address!.street` 避免了报错。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "The non-null assertion operator should be used sparingly as refactoring of the component\n might break this constraint.",
+ "translation": "应该保守点使用非空断言操作符,因为将来对组件的重构可能会破坏这个约束。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "In this example it is recommended to include the checking of `address`\n in the `*ngIf`as shown below:",
+ "translation": "这个例子中,更建议在 `*ngIf` 中包含对 `address` 的检查,代码如下:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "### Disabling type checking using `$any()`",
+ "translation": "### 使用 `$any()` 禁用类型检查",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "Disable checking of a binding expression by surrounding the expression\n in a call to the [`$any()` cast pseudo-function](guide/template-syntax).\n The compiler treats it as a cast to the `any` type just like in TypeScript when a ``\n or `as any` cast is used.",
+ "translation": "可以通过把绑定表达式包含在[类型转换伪函数 `$any()` ](guide/template-syntax) 中来禁用类型检查。\n 编译器会像在 TypeScript 中使用 `` 或 `as any` 进行类型转换一样对待它。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "In the following example, the error `Property addresss does not exist` is suppressed\n by casting `person` to the `any` type.",
+ "translation": "下面的例子中,通过把 `person` 转换成 `any` 类型,忽略了 `Property addresss does not exist` 错误。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
{
"original": "## Summary",
"translation": "## 小结",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
},
+ {
+ "original": "* What the AOT compiler does and why it is important.",
+ "translation": "什么是 AOT 编译器,以及它为什么如此重要。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "* Why metadata must be written in a subset of JavaScript.",
+ "translation": "为何元数据必须使用 JavaScript 的一个子集来书写。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "* What that subset is.",
+ "translation": "这个子集是什么。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "* Other restrictions on metadata definition.",
+ "translation": "定义元数据时的其它限制。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "* Macro-functions and macro-static methods.",
+ "translation": "宏函数和静态宏函数。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "* Compiler errors related to metadata.",
+ "translation": "与元数据有关的编译器错误。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
+ {
+ "original": "* Validation of binding expressions",
+ "translation": "验证绑定表达式。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/aot-compiler.md"
+ },
{
"original": "Property",
"translation": "属性",
@@ -1551,17 +2496,17 @@
},
{
"original": "You write Angular applications by composing HTML *templates* with Angularized markup,\nwriting *component* classes to manage those templates, adding application logic in *services*,\nand boxing components and services in *modules*.",
- "translation": "我们是这样写 Angular 应用的:用 Angular 扩展语法编写 HTML *模板*,\n用*组件*类管理这些模板,用*服务*添加应用逻辑,\n用*模块*打包发布组件与服务。",
+ "translation": "你是这样编写 Angular 应用的:用 Angular 扩展语法编写 HTML *模板*,\n用*组件*类管理这些模板,用*服务*添加应用逻辑,\n用*模块*打包发布组件与服务。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "Then you launch the app by *bootstrapping* the _root module_.\nAngular takes over, presenting your application content in a browser and\nresponding to user interactions according to the instructions you've provided.",
- "translation": "然后,我们通过*引导*_根模块_来启动该应用。\nAngular 在浏览器中接管、展现应用的内容,并根据我们提供的操作指令响应用户的交互。",
+ "translation": "然后,你通过*引导**根模块*来启动该应用。\nAngular 在浏览器中接管、展现应用的内容,并根据你提供的操作指令响应用户的交互。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "Of course, there is more to it than this.\nYou'll learn the details in the pages that follow. For now, focus on the big picture.",
- "translation": "当然,这只是冰山一角。后面我们将学习更多的细节。不过,目前我们还是先关注全景图吧。",
+ "translation": "当然,这只是冰山一角。后面你还会学到更多的细节。不过,目前还是先关注全景图吧。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1576,7 +2521,7 @@
},
{
"original": "Angular apps are modular and Angular has its own modularity system called _NgModules_.",
- "translation": "Angular 应用是模块化的,并且 Angular 有自己的模块系统,它被称为 _Angular 模块_或 _NgModules_。",
+ "translation": "Angular 应用是模块化的,并且 Angular 有自己的模块系统,它被称为 *Angular 模块*或 *NgModules*。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1586,17 +2531,17 @@
},
{
"original": "Every Angular app has at least one NgModule class, [the _root module_](guide/bootstrapping \"Bootstrapping\"),\nconventionally named `AppModule`.",
- "translation": "每个 Angular 应用至少有一个模块([_根模块_](guide/bootstrapping \"引导启动\")),习惯上命名为`AppModule`。",
+ "translation": "每个 Angular 应用至少有一个模块([*根模块*](guide/bootstrapping \"引导启动\")),习惯上命名为 `AppModule`。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "While the _root module_ may be the only module in a small application, most apps have many more\n_feature modules_, each a cohesive block of code dedicated to an application domain,\na workflow, or a closely related set of capabilities.",
- "translation": "_根模块_在一些小型应用中可能是唯一的模块,大多数应用会有很多_特性模块_,每个模块都是一个内聚的代码块专注于某个应用领域、工作流或紧密相关的功能。",
+ "translation": "*根模块*在一些小型应用中可能是唯一的模块,大多数应用会有很多*特性模块*,每个模块都是一个内聚的代码块专注于某个应用领域、工作流或紧密相关的功能。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "An NgModule, whether a _root_ or _feature_, is a class with an `@NgModule` decorator.",
- "translation": "Angular 模块(无论是_根模块_还是_特性模块_)都是一个带有`@NgModule`装饰器的类。",
+ "translation": "Angular 模块(无论是*根模块*还是*特性模块*)都是一个带有 `@NgModule` 装饰器的类。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1606,12 +2551,12 @@
},
{
"original": "`NgModule` is a decorator function that takes a single metadata object whose properties describe the module.\nThe most important properties are:",
- "translation": "`NgModule`是一个装饰器函数,它接收一个用来描述模块属性的元数据对象。其中最重要的属性是:",
+ "translation": "`NgModule` 是一个装饰器函数,它接收一个用来描述模块属性的元数据对象。其中最重要的属性是:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "* `declarations` - the _view classes_ that belong to this module.\nAngular has three kinds of view classes: [components](guide/architecture#components), [directives](guide/architecture#directives), and [pipes](guide/pipes).",
- "translation": "`declarations` - 声明本模块中拥有的_视图类_。Angular 有三种视图类:[组件](guide/architecture#components)、[指令](guide/architecture#directives)和[管道](guide/pipes)。",
+ "translation": "`declarations` - 声明本模块中拥有的*视图类*。Angular 有三种视图类:[组件](guide/architecture#components)、[指令](guide/architecture#directives)和[管道](guide/pipes)。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1621,7 +2566,7 @@
},
{
"original": "* `imports` - other modules whose exported classes are needed by component templates declared in _this_ module.",
- "translation": "`imports` - _本_模块声明的组件模板需要的类所在的其它模块。",
+ "translation": "`imports` - *本*模块声明的组件模板需要的类所在的其它模块。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1631,7 +2576,7 @@
},
{
"original": "* `bootstrap` - the main application view, called the _root component_,\nthat hosts all other app views. Only the _root module_ should set this `bootstrap` property.",
- "translation": "`bootstrap` - 指定应用的主视图(称为_根组件_),它是所有其它视图的宿主。只有_根模块_才能设置`bootstrap`属性。",
+ "translation": "`bootstrap` - 指定应用的主视图(称为*根组件*),它是所有其它视图的宿主。只有*根模块*才能设置 `bootstrap` 属性。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1641,12 +2586,12 @@
},
{
"original": "The `export` of `AppComponent` is just to show how to use the `exports` array to export a component; it isn't actually necessary in this example. A root module has no reason to _export_ anything because other components don't need to _import_ the root module.",
- "translation": "`AppComponent`的`export`语句只是用于演示如何导出的,它在这个例子中并不是必须的。根模块不需要_导出_任何东西,因为其它组件不需要导入根模块。",
+ "translation": "`AppComponent` 的 `export` 语句只是用于演示如何导出的,它在这个例子中并不是必须的。根模块不需要*导出*任何东西,因为其它组件不需要导入根模块。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "Launch an application by _bootstrapping_ its root module.\nDuring development you're likely to bootstrap the `AppModule` in a `main.ts` file like this one.",
- "translation": "我们通过_引导_根模块来启动应用。\n在开发期间,你通常在一个`main.ts`文件中引导`AppModule`,就像这样:",
+ "translation": "通过*引导*根模块来启动应用。\n在开发期间,你通常在一个 `main.ts` 文件中引导 `AppModule`,就像这样:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1656,7 +2601,7 @@
},
{
"original": "The NgModule — a class decorated with `@NgModule` — is a fundamental feature of Angular.",
- "translation": "NgModule(一个带`@NgModule`装饰器的类)是 Angular 的基础特性之一。",
+ "translation": "NgModule(一个带 `@NgModule` 装饰器的类)是 Angular 的基础特性之一。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1666,7 +2611,7 @@
},
{
"original": "In JavaScript each _file_ is a module and all objects defined in the file belong to that module.\nThe module declares some objects to be public by marking them with the `export` key word.\nOther JavaScript modules use *import statements* to access public objects from other modules.",
- "translation": "JavaScript 中,每个_文件_是一个模块,文件中定义的所有对象都从属于那个模块。\n通过`export`关键字,模块可以把它的某些对象声明为公共的。\n其它 JavaScript 模块可以使用*import 语句*来访问这些公共对象。",
+ "translation": "JavaScript 中,每个*文件*是一个模块,文件中定义的所有对象都从属于那个模块。\n通过 `export` 关键字,模块可以把它的某些对象声明为公共的。\n其它 JavaScript 模块可以使用*import 语句*来访问这些公共对象。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1676,7 +2621,7 @@
},
{
"original": "These are two different and _complementary_ module systems. Use them both to write your apps.",
- "translation": "这两个模块化系统是互补的,我们在写程序时都会用到。",
+ "translation": "这两个模块化系统是不同但*互补*的,你在写程序时都会用到。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1691,27 +2636,27 @@
},
{
"original": "Each Angular library name begins with the `@angular` prefix.",
- "translation": "每个 Angular 库的名字都带有`@angular`前缀。",
+ "translation": "每个 Angular 库的名字都带有 `@angular` 前缀。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "You install them with the **npm** package manager and import parts of them with JavaScript `import` statements.",
- "translation": "用 **npm** 包管理工具安装它们,用 JavaScript 的`import`语句导入其中某些部件。",
+ "translation": "用 **npm** 包管理工具安装它们,用 JavaScript 的 `import` 语句导入其中某些部件。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "For example, import Angular's `Component` decorator from the `@angular/core` library like this:",
- "translation": "例如,象下面这样,从`@angular/core`库中导入`Component`装饰器:",
+ "translation": "例如,象下面这样,从 `@angular/core` 库中导入 `Component` 装饰器:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "You also import NgModules from Angular _libraries_ using JavaScript import statements:",
- "translation": "还可以使用 JavaScript 的导入语句从 Angular _库_中导入 Angular _模块_:",
+ "translation": "还可以使用 JavaScript 的导入语句从 Angular *库*中导入 Angular *模块*:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "In the example of the simple root module above, the application module needs material from within that `BrowserModule`. To access that material, add it to the `@NgModule` metadata `imports` like this.",
- "translation": "在上面那个简单的根模块的例子中,应用模块需要`BrowserModule`的某些素材。要访问这些素材,就得把它加入`@NgModule`元数据的`imports`中,就像这样:",
+ "translation": "在上面那个简单的根模块的例子中,应用模块需要 `BrowserModule` 的某些素材。要访问这些素材,就得把它加入 `@NgModule` 元数据的 `imports` 中,就像这样:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1736,7 +2681,7 @@
},
{
"original": "A _component_ controls a patch of screen called a *view*.",
- "translation": "_组件_负责控制屏幕上的一小块区域,我们称之为*视图*。",
+ "translation": "*组件*负责控制屏幕上的一小块区域叫做*视图*。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1761,17 +2706,17 @@
},
{
"original": "You define a component's application logic—what it does to support the view—inside a class.\nThe class interacts with the view through an API of properties and methods.",
- "translation": "我们在类中定义组件的应用逻辑,为视图提供支持。\n组件通过一些由属性和方法组成的 API 与视图交互。",
+ "translation": "你在类中定义组件的应用逻辑,为视图提供支持。\n组件通过一些由属性和方法组成的 API 与视图交互。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "For example, this `HeroListComponent` has a `heroes` property that returns an array of heroes\nthat it acquires from a service.\n`HeroListComponent` also has a `selectHero()` method that sets a `selectedHero` property when the user clicks to choose a hero from that list.",
- "translation": "例如,`HeroListComponent`有一个`heroes`属性,它返回一个英雄数组,这个数组从一个服务获得。\n`HeroListComponent`还有一个当用户从列表中点选一个英雄时设置`selectedHero`属性的`selectHero()`方法。",
+ "translation": "例如,`HeroListComponent` 有一个 `heroes` 属性,它返回一个英雄数组,这个数组从一个服务获得。\n`HeroListComponent` 还有一个当用户从列表中点选一个英雄时设置 `selectedHero` 属性的 `selectHero()` 方法。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "Angular creates, updates, and destroys components as the user moves through the application.\nYour app can take action at each moment in this lifecycle through optional [lifecycle hooks](guide/lifecycle-hooks), like `ngOnInit()` declared above.",
- "translation": "当用户在这个应用中漫游时, Angular 会创建、更新和销毁组件。\n应用可以通过[生命周期钩子](guide/lifecycle-hooks)在组件生命周期的各个时间点上插入自己的操作,例如上面声明的`ngOnInit()`。",
+ "translation": "当用户在这个应用中漫游时, Angular 会创建、更新和销毁组件。\n应用可以通过[生命周期钩子](guide/lifecycle-hooks)在组件生命周期的各个时间点上插入自己的操作,例如上面声明的 `ngOnInit()`。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1781,32 +2726,32 @@
},
{
"original": "You define a component's view with its companion **template**. A template is a form of HTML\nthat tells Angular how to render the component.",
- "translation": "我们通过组件的自带的**模板**来定义组件视图。模板以 HTML 形式存在,告诉 Angular 如何渲染组件。",
+ "translation": "你通过组件的自带的**模板**来定义组件视图。模板以 HTML 形式存在,告诉 Angular 如何渲染组件。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "A template looks like regular HTML, except for a few differences. Here is a\ntemplate for our `HeroListComponent`:",
- "translation": "多数情况下,模板看起来很像标准 HTML,当然也有一点不同的地方。下面是`HeroListComponent`组件的一个模板:",
+ "translation": "多数情况下,模板看起来很像标准 HTML,当然也有一点不同的地方。下面是 `HeroListComponent` 组件的一个模板:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "Although this template uses typical HTML elements like `
` and `
`, it also has some differences. Code like `*ngFor`, `{{hero.name}}`, `(click)`, `[hero]`, and `` uses Angular's [template syntax](guide/template-syntax).",
- "translation": "模板除了可以使用像`
`和`
`这样的典型的 HTML 元素,还能使用其它元素。\n例如,像`*ngFor`、`{{hero.name}}`、`(click)`、`[hero]`和``这样的代码使用了 Angular 的[模板语法](guide/template-syntax)。",
+ "translation": "模板除了可以使用像 `
` 和 `
` 这样的典型的 HTML 元素,还能使用其它元素。\n例如,像 `*ngFor`、`{{hero.name}}`、`(click)`、`[hero]` 和 `` 这样的代码使用了 Angular 的[模板语法](guide/template-syntax)。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "In the last line of the template, the `` tag is a custom element that represents a new component, `HeroDetailComponent`.",
- "translation": "在模板的最后一行,``标签就是一个用来表示新组件`HeroDetailComponent`的自定义元素。",
+ "translation": "在模板的最后一行,`` 标签就是一个用来表示新组件 `HeroDetailComponent` 的自定义元素。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "The `HeroDetailComponent` is a *different* component than the `HeroListComponent` you've been reviewing.\nThe `HeroDetailComponent` (code not shown) presents facts about a particular hero, the\nhero that the user selects from the list presented by the `HeroListComponent`.\nThe `HeroDetailComponent` is a **child** of the `HeroListComponent`.",
- "translation": "`HeroDetailComponent`跟以前见到过的`HeroListComponent`是*不同*的组件。\n`HeroDetailComponent`(代码未显示)用于展现一个特定英雄的情况,这个英雄是用户从`HeroListComponent`列表中选择的。\n`HeroDetailComponent`是`HeroListComponent`的*子组件*。",
+ "translation": "`HeroDetailComponent` 跟以前见到过的 `HeroListComponent` 是*不同*的组件。\n`HeroDetailComponent`(代码未显示)用于展现一个特定英雄的情况,这个英雄是用户从 `HeroListComponent` 列表中选择的。\n`HeroDetailComponent` 是 `HeroListComponent` 的*子组件*。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "Notice how `` rests comfortably among native HTML elements. Custom components mix seamlessly with native HTML in the same layouts.",
- "translation": "注意到了吗?``舒适地躺在原生 HTML 元素之间。\n自定义组件和原生 HTML 在同一布局中融合得天衣无缝。",
+ "translation": "注意到了吗?`` 舒适地躺在原生 HTML 元素之间。\n自定义组件和原生 HTML 在同一布局中融合得天衣无缝。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1821,42 +2766,42 @@
},
{
"original": "[Looking back at the code](guide/architecture#component-code) for `HeroListComponent`, you can see that it's just a class.\nThere is no evidence of a framework, no \"Angular\" in it at all.",
- "translation": "[回头看看](guide/architecture#component-code)`HeroListComponent`就会明白:它只是一个类。\n一点框架的痕迹也没有,里面完全没有出现 \"Angular\" 的字样。",
+ "translation": "[回头看看](guide/architecture#component-code)`HeroListComponent` 就会明白:它只是一个类。\n一点框架的痕迹也没有,里面完全没有出现 \"Angular\" 的字样。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "In fact, `HeroListComponent` really is *just a class*. It's not a component until you *tell Angular about it*.",
- "translation": "实际上,`HeroListComponent`真的*只是一个类*。直到我们*告诉 Angular* 它是一个组件。",
+ "translation": "实际上,`HeroListComponent` 真的*只是一个类*。直到你*告诉 Angular* 它是一个组件。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "To tell Angular that `HeroListComponent` is a component, attach **metadata** to the class.",
- "translation": "要告诉 Angular `HeroListComponent`是个组件,只要把**元数据**附加到这个类。",
+ "translation": "要告诉 Angular `HeroListComponent` 是个组件,只要把**元数据**附加到这个类。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "In TypeScript, you attach metadata by using a **decorator**.\nHere's some metadata for `HeroListComponent`:",
- "translation": "在TypeScript中,我们用**装饰器 (decorator) **来附加元数据。\n下面就是`HeroListComponent`的一些元数据。",
+ "translation": "在 TypeScript 中,你要用**装饰器 (decorator) **来附加元数据。\n下面就是 `HeroListComponent` 的一些元数据。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "Here is the `@Component` decorator, which identifies the class\nimmediately below it as a component class.",
- "translation": "这里看到`@Component`装饰器,它把紧随其后的类标记成了组件类。",
+ "translation": "这里看到 `@Component` 装饰器,它把紧随其后的类标记成了组件类。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "The `@Component` decorator takes a required configuration object with the\ninformation Angular needs to create and present the component and its view.",
- "translation": "`@Component`装饰器能接受一个配置对象, Angular 会基于这些信息创建和展示组件及其视图。",
+ "translation": "`@Component` 装饰器能接受一个配置对象, Angular 会基于这些信息创建和展示组件及其视图。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "Here are a few of the most useful `@Component` configuration options:",
- "translation": "`@Component`的配置项包括:",
+ "translation": "`@Component` 的配置项包括:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "* `selector`: CSS selector that tells Angular to create and insert an instance of this component\nwhere it finds a `` tag in *parent* HTML.\nFor example, if an app's HTML contains ``, then\nAngular inserts an instance of the `HeroListComponent` view between those tags.",
- "translation": "`selector`: CSS 选择器,它告诉 Angular 在*父级* HTML 中查找``标签,创建并插入该组件。\n 例如,如果应用的 HTML 包含``, Angular 就会把`HeroListComponent`的一个实例插入到这个标签中。",
+ "translation": "`selector`: CSS 选择器,它告诉 Angular 在*父级* HTML 中查找 `` 标签,创建并插入该组件。\n 例如,如果应用的 HTML 包含 ``, Angular 就会把 `HeroListComponent` 的一个实例插入到这个标签中。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1866,12 +2811,12 @@
},
{
"original": "* `providers`: array of **dependency injection providers** for services that the component requires.\nThis is one way to tell Angular that the component's constructor requires a `HeroService`\nso it can get the list of heroes to display.",
- "translation": "`providers` - 组件所需服务的*依赖注入提供商*数组。\n这是在告诉 Angular:该组件的构造函数需要一个`HeroService`服务,这样组件就可以从服务中获得英雄数据。",
+ "translation": "`providers` - 组件所需服务的*依赖注入提供商*数组。\n这是在告诉 Angular:该组件的构造函数需要一个 `HeroService` 服务,这样组件就可以从服务中获得英雄数据。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "The metadata in the `@Component` tells Angular where to get the major building blocks you specify for the component.",
- "translation": "`@Component`里面的元数据会告诉 Angular 从哪里获取你为组件指定的主要的构建块。",
+ "translation": "`@Component` 里面的元数据会告诉 Angular 从哪里获取你为组件指定的主要的构建块。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1881,7 +2826,7 @@
},
{
"original": "Apply other metadata decorators in a similar fashion to guide Angular behavior.\n`@Injectable`, `@Input`, and `@Output` are a few of the more popular decorators.",
- "translation": "其它元数据装饰器用类似的方式来指导 Angular 的行为。\n例如`@Injectable`、`@Input`和`@Output`等是一些最常用的装饰器。",
+ "translation": "其它元数据装饰器用类似的方式来指导 Angular 的行为。\n例如 `@Injectable`、`@Input` 和 `@Output` 等是一些最常用的装饰器。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1896,12 +2841,12 @@
},
{
"original": "Without a framework, you would be responsible for pushing data values into the HTML controls and turning user responses\ninto actions and value updates. Writing such push/pull logic by hand is tedious, error-prone, and a nightmare to\nread as any experienced jQuery programmer can attest.",
- "translation": "如果没有框架,我们就得自己把数据值推送到 HTML 控件中,并把用户的反馈转换成动作和值更新。\n如果手工写代码来实现这些推/拉逻辑,肯定会枯燥乏味、容易出错,读起来简直是噩梦 —— 写过 jQuery 的程序员大概都对此深有体会。",
+ "translation": "如果没有框架,你就得自己把数据值推送到 HTML 控件中,并把用户的反馈转换成动作和值更新。\n如果手工写代码来实现这些推/拉逻辑,肯定会枯燥乏味、容易出错,读起来简直是噩梦 —— 写过 jQuery 的程序员大概都对此深有体会。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "Angular supports **data binding**,\na mechanism for coordinating parts of a template with parts of a component.\nAdd binding markup to the template HTML to tell Angular how to connect both sides.",
- "translation": "Angular 支持**数据绑定**,一种让模板的各部分与组件的各部分相互合作的机制。\n我们往模板 HTML 中添加绑定标记,来告诉 Angular 如何把二者联系起来。",
+ "translation": "Angular 支持**数据绑定**,一种让模板的各部分与组件的各部分相互合作的机制。\n往模板 HTML 中添加绑定标记,来告诉 Angular 如何把二者联系起来。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1916,22 +2861,22 @@
},
{
"original": "* The `{{hero.name}}` [*interpolation*](guide/displaying-data#interpolation)\ndisplays the component's `hero.name` property value within the `
` 标签中显示组件的 `hero.name` 属性的值。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "* The `[hero]` [*property binding*](guide/template-syntax#property-binding) passes the value of `selectedHero` from\nthe parent `HeroListComponent` to the `hero` property of the child `HeroDetailComponent`.",
- "translation": "`[hero]`[*属性绑定*](guide/template-syntax#property-binding)把父组件`HeroListComponent`的`selectedHero`的值传到子组件`HeroDetailComponent`的`hero`属性中。",
+ "translation": "`[hero]`[*属性绑定*](guide/template-syntax#property-binding)把父组件 `HeroListComponent` 的 `selectedHero` 的值传到子组件 `HeroDetailComponent` 的 `hero` 属性中。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "* The `(click)` [*event binding*](guide/user-input#click) calls the component's `selectHero` method when the user clicks a hero's name.",
- "translation": "`(click)` [*事件绑定*](guide/user-input#click)在用户点击英雄的名字时调用组件的`selectHero`方法。",
+ "translation": "`(click)` [*事件绑定*](guide/user-input#click)在用户点击英雄的名字时调用组件的 `selectHero` 方法。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "**Two-way data binding** is an important fourth form\nthat combines property and event binding in a single notation, using the `ngModel` directive.\nHere's an example from the `HeroDetailComponent` template:",
- "translation": "**双向数据绑定**是重要的第四种绑定形式,它使用`ngModel`指令组合了属性绑定和事件绑定的功能。\n下面是`HeroDetailComponent`模板的范例:",
+ "translation": "**双向数据绑定**是重要的第四种绑定形式,它使用 `ngModel` 指令组合了属性绑定和事件绑定的功能。\n下面是 `HeroDetailComponent` 模板的范例:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1966,17 +2911,17 @@
},
{
"original": "A directive is a class with a `@Directive` decorator.\nA component is a *directive-with-a-template*;\na `@Component` decorator is actually a `@Directive` decorator extended with template-oriented features.",
- "translation": "组件是一个*带模板的指令*;`@Component`装饰器实际上就是一个`@Directive`装饰器,只是扩展了一些面向模板的特性。",
+ "translation": "组件是一个*带模板的指令*;`@Component` 装饰器实际上就是一个 `@Directive` 装饰器,只是扩展了一些面向模板的特性。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "While **a component is technically a directive**,\n components are so distinctive and central to Angular applications that this architectural overview separates components from directives.",
- "translation": "虽然**严格来说组件就是一个指令**,但是组件非常独特,并在 Angular 中位于中心地位,所以在架构概览中,我们把组件从指令中独立了出来。",
+ "translation": "虽然**严格来说组件就是一个指令**,但是组件非常独特,并在 Angular 中位于中心地位,所以在架构概览中把组件从指令中独立了出来。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "Two *other* kinds of directives exist: _structural_ and _attribute_ directives.",
- "translation": "还有两种*其它*类型的指令:_结构型_指令和_属性 (attribute) 型_指令。",
+ "translation": "还有两种*其它*类型的指令:*结构型*指令和*属性 (attribute) 型*指令。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -1996,12 +2941,12 @@
},
{
"original": "* [`*ngFor`](guide/displaying-data#ngFor) tells Angular to stamp out one `
` per hero in the `heroes` list.",
- "translation": "[`*ngFor`](guide/displaying-data#ngFor)告诉 Angular 为`heroes`列表中的每个英雄生成一个`
` 标签。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "* [`*ngIf`](guide/displaying-data#ngIf) includes the `HeroDetail` component only if a selected hero exists.",
- "translation": "[`*ngIf`](guide/displaying-data#ngIf)表示只有在选择的英雄存在时,才会包含`HeroDetail`组件。",
+ "translation": "[`*ngIf`](guide/displaying-data#ngIf)表示只有在选择的英雄存在时,才会包含 `HeroDetail` 组件。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -2011,7 +2956,7 @@
},
{
"original": "The `ngModel` directive, which implements two-way data binding, is\nan example of an attribute directive. `ngModel` modifies the behavior of\nan existing element (typically an ``)\nby setting its display value property and responding to change events.",
- "translation": "`ngModel`指令就是属性型指令的一个例子,它实现了双向数据绑定。\n`ngModel`修改现有元素(一般是``)的行为:设置其显示属性值,并响应 change 事件。",
+ "translation": "`ngModel` 指令就是属性型指令的一个例子,它实现了双向数据绑定。\n`ngModel` 修改现有元素(一般是 ``)的行为:设置其显示属性值,并响应 change 事件。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -2021,7 +2966,7 @@
},
{
"original": "Of course, you can also write your own directives. Components such as\n`HeroListComponent` are one kind of custom directive.",
- "translation": "当然,我们也能编写自己的指令。像`HeroListComponent`这样的组件就是一种自定义指令。",
+ "translation": "当然,你也能编写自己的指令。像 `HeroListComponent` 这样的组件就是一种自定义指令。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -2086,7 +3031,7 @@
},
{
"original": "Here's a `HeroService` that uses a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) to fetch heroes.\nThe `HeroService` depends on the `Logger` service and another `BackendService` that handles the server communication grunt work.",
- "translation": "下面是`HeroService`类,用于获取英雄数据,并通过一个已解析的[承诺 (Promise)](http://exploringjs.com/es6/ch_promises.html) 返回它们。\n`HeroService`还依赖于`Logger`服务和另一个用于处理服务器通讯的`BackendService`服务。",
+ "translation": "下面是 `HeroService` 类,用于获取英雄数据,并通过一个已解析的[承诺 (Promise)](http://exploringjs.com/es6/ch_promises.html) 返回它们。\n`HeroService` 还依赖于 `Logger` 服务和另一个用于处理服务器通讯的 `BackendService` 服务。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -2101,17 +3046,17 @@
},
{
"original": "A component's job is to enable the user experience and nothing more. It mediates between the view (rendered by the template)\nand the application logic (which often includes some notion of a _model_).\nA good component presents properties and methods for data binding.\nIt delegates everything nontrivial to services.",
- "translation": "组件的任务就是提供用户体验,仅此而已。它介于视图(由模板渲染)和应用逻辑(通常包括_模型_的某些概念)之间。\n设计良好的组件为数据绑定提供属性和方法,把其它琐事都委托给服务。",
+ "translation": "组件的任务就是提供用户体验,仅此而已。它介于视图(由模板渲染)和应用逻辑(通常包括*模型*的某些概念)之间。\n设计良好的组件为数据绑定提供属性和方法,把其它琐事都委托给服务。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "Angular doesn't *enforce* these principles.\nIt won't complain if you write a \"kitchen sink\" component with 3000 lines.",
- "translation": "Angular 不会*强制要求*我们遵循这些原则。\n即使我们花 3000 行代码写了一个“厨房洗碗槽”组件,它也不会抱怨什么。",
+ "translation": "Angular 不会*强行保障*这些原则。\n即使你花 3000 行代码写了一个“厨房洗碗槽”组件,它也不会抱怨什么。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "Angular does help you *follow* these principles by making it easy to factor your\napplication logic into services and make those services available to components through *dependency injection*.",
- "translation": "Angular 帮助我们*遵循*这些原则 —— 它让我们能轻易地把应用逻辑拆分到服务,并通过*依赖注入*来在组件中使用这些服务。",
+ "translation": "Angular 帮助你*遵循*这些原则 —— 它让你能轻易地把应用逻辑拆分到服务,并通过*依赖注入*来在组件中使用这些服务。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -2126,7 +3071,7 @@
},
{
"original": "Angular can tell which services a component needs by looking at the types of its constructor parameters.\nFor example, the constructor of your `HeroListComponent` needs a `HeroService`:",
- "translation": "Angular 通过查看构造函数的参数类型得知组件需要哪些服务。\n例如,`HeroListComponent`组件的构造函数需要一个`HeroService`服务:",
+ "translation": "Angular 通过查看构造函数的参数类型得知组件需要哪些服务。\n例如,`HeroListComponent` 组件的构造函数需要一个 `HeroService` 服务:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -2141,22 +3086,22 @@
},
{
"original": "The process of `HeroService` injection looks a bit like this:",
- "translation": "`HeroService`注入的过程差不多是这样的:",
+ "translation": "`HeroService` 注入的过程差不多是这样的:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "If the injector doesn't have a `HeroService`, how does it know how to make one?",
- "translation": "如果注入器还没有`HeroService`,它怎么知道该如何创建一个呢?",
+ "translation": "如果注入器还没有 `HeroService`,它怎么知道该如何创建一个呢?",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "In brief, you must have previously registered a **provider** of the `HeroService` with the injector.\nA provider is something that can create or return a service, typically the service class itself.",
- "translation": "简单点说,我们必须先用注入器(injector)为`HeroService`注册一个**提供商(provider)**。\n提供商用来创建或返回服务,通常就是这个服务类本身(相当于`new HeroService()`)。",
+ "translation": "简单点说,你必须先用注入器(injector)为 `HeroService` 注册一个**提供商(provider)**。\n提供商用来创建或返回服务,通常就是这个服务类本身(相当于 `new HeroService()`)。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
"original": "You can register providers in modules or in components.",
- "translation": "我们可以在模块中或组件中注册提供商。",
+ "translation": "你可以在模块中或组件中注册提供商。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -2166,7 +3111,7 @@
},
{
"original": "Alternatively, register at a component level in the `providers` property of the `@Component` metadata:",
- "translation": "或者,也可以在`@Component`元数据中的`providers`属性中把它注册在组件层:",
+ "translation": "或者,也可以在 `@Component` 元数据中的 `providers` 属性中把它注册在组件层:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -2221,7 +3166,7 @@
},
{
"original": "You've learned the basics about the eight main building blocks of an Angular application:",
- "translation": "我们学到的这些只是关于 Angular 应用程序的八个主要构造块的基础知识:",
+ "translation": "你学到的这些只是关于 Angular 应用程序的八个主要构造块的基础知识:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -2266,7 +3211,7 @@
},
{
"original": "That's a foundation for everything else in an Angular application,\nand it's more than enough to get going.\nBut it doesn't include everything you need to know.",
- "translation": "这是 Angular 应用程序中所有其它东西的基础,要使用 Angular,以这些作为开端就绰绰有余了。\n但它仍然没有包含我们需要知道的全部。",
+ "translation": "这是 Angular 应用程序中所有其它东西的基础,要使用 Angular,以这些作为开端就绰绰有余了。\n但它仍然没有包含你需要知道的一切。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
{
@@ -2304,11 +3249,6 @@
"translation": "> [**生命周期钩子**](guide/lifecycle-hooks):通过实现生命周期钩子接口,可以切入组件生命中的几个关键点:从创建到销毁。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
},
- {
- "original": "> [**Pipes**](guide/pipes): Use pipes in your templates to improve the user experience by transforming values for display. Consider this `currency` pipe expression:\n>\n> > `price | currency:'USD':true`\n>\n> It displays a price of 42.33 as `$42.33`.",
- "translation": "> [**管道**](guide/pipes):在模板中使用管道转换成用于显示的值,以增强用户体验。例如,`currency`管道表达式:\n>\n> > `price | currency:'USD':true`\n>\n> 它把价格“42.33”显示为`$42.33`。",
- "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/architecture.md"
- },
{
"original": "> [**Router**](guide/router): Navigate from page to page within the client\n application and never leave the browser.",
"translation": "> [**路由器**](guide/router):在应用程序客户端的页面间导航,并且不离开浏览器。",
@@ -2381,7 +3321,7 @@
},
{
"original": "An attribute directive minimally requires building a controller class annotated with\n`@Directive`, which specifies the selector that identifies\nthe attribute.\nThe controller class implements the desired directive behavior.",
- "translation": "属性型指令至少需要一个带有`@Directive`装饰器的控制器类。该装饰器指定了一个用于标识属性的选择器。\n控制器类实现了指令需要的指令行为。",
+ "translation": "属性型指令至少需要一个带有 `@Directive` 装饰器的控制器类。该装饰器指定了一个用于标识属性的选择器。\n控制器类实现了指令需要的指令行为。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
@@ -2401,22 +3341,22 @@
},
{
"original": "The CLI creates `src/app/highlight.directive.ts`, a corresponding test file (`.../spec.ts`, and _declares_ the directive class in the root `AppModule`.",
- "translation": "CLI 会创建`src/app/highlight.directive.ts`及相应的测试文件(`.../spec.ts`),并且在根模块`AppModule`中声明这个指令类。",
+ "translation": "CLI 会创建 `src/app/highlight.directive.ts` 及相应的测试文件(`.../spec.ts`),并且在根模块 `AppModule` 中声明这个指令类。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "_Directives_ must be declared in [Angular Modules](guide/ngmodules) in the same manner as _components_.",
- "translation": "和**组件**一样,这些**指令**也必须在[Angular模块](guide/ngmodules)中进行声明。",
+ "translation": "和**组件**一样,这些**指令**也必须在[Angular 模块](guide/ngmodules)中进行声明。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "The generated `src/app/highlight.directive.ts` is as follows:",
- "translation": "生成的`src/app/highlight.directive.ts`文件如下:",
+ "translation": "生成的 `src/app/highlight.directive.ts` 文件如下:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "The imported `Directive` symbol provides the Angular the `@Directive` decorator.",
- "translation": "这里导入的`Directive`符号提供了 Angular 的 `@Directive` 装饰器。",
+ "translation": "这里导入的 `Directive` 符号提供了 Angular 的 `@Directive` 装饰器。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
@@ -2441,32 +3381,32 @@
},
{
"original": "Though *highlight* would be a more concise selector than *appHighlight* and it would work,\nthe best practice is to prefix selector names to ensure\nthey don't conflict with standard HTML attributes.\nThis also reduces the risk of colliding with third-party directive names.\nThe CLI added the `app` prefix for you.",
- "translation": "尽管*highlight* 是一个比 *myHighlight* 更简洁的名字,而且它确实也能工作。\n但是最佳实践是在选择器名字前面添加前缀,以确保它们不会与标准 HTML 属性冲突。\n它同时减少了与第三方指令名字发生冲突的危险。",
+ "translation": "尽管 *highlight* 是一个比 *myHighlight* 更简洁的名字,而且它确实也能工作。\n但是最佳实践是在选择器名字前面添加前缀,以确保它们不会与标准 HTML 属性冲突。\n它同时减少了与第三方指令名字发生冲突的危险。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Make sure you do **not** prefix the `highlight` directive name with **`ng`** because\nthat prefix is reserved for Angular and using it could cause bugs that are difficult to diagnose.",
- "translation": "确认你**没有**给`highlight`指令添加**`ng`**前缀。\n那个前缀属于 Angular,使用它可能导致难以诊断的 bug。例如,这个简短的前缀`my`可以帮助你区分自定义指令。",
+ "translation": "确认你**没有**给 `highlight` 指令添加**`ng`**前缀。\n那个前缀属于 Angular,使用它可能导致难以诊断的 bug。例如,这个简短的前缀 `my` 可以帮助你区分自定义指令。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "After the `@Directive` metadata comes the directive's controller class,\ncalled `HighlightDirective`, which contains the (currently empty) logic for the directive.\nExporting `HighlightDirective` makes the directive accessible.",
- "translation": "紧跟在`@Directive`元数据之后的就是该指令的控制器类,名叫`HighlightDirective`,它包含了该指令的逻辑(目前为空逻辑)。然后导出`HighlightDirective`,以便它能在别处访问到。",
+ "translation": "紧跟在 `@Directive` 元数据之后的就是该指令的控制器类,名叫 `HighlightDirective`,它包含了该指令的逻辑(目前为空逻辑)。然后导出 `HighlightDirective`,以便它能在别处访问到。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Now edit the generated `src/app/highlight.directive.ts` to look as follows:",
- "translation": "现在,把刚才生成的`src/app/highlight.directive.ts`编辑成这样:",
+ "translation": "现在,把刚才生成的 `src/app/highlight.directive.ts` 编辑成这样:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "The `import` statement specifies an additional `ElementRef` symbol from the Angular `core` library:",
- "translation": "`import`语句还从 Angular 的 `core` 库中导入了一个 `ElementRef` 符号。",
+ "translation": "`import` 语句还从 Angular 的 `core` 库中导入了一个 `ElementRef` 符号。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "You use the `ElementRef`in the directive's constructor\nto [inject](guide/dependency-injection) a reference to the host DOM element, \nthe element to which you applied `appHighlight`.",
- "translation": "我们可以在指令的构造函数中注入`ElementRef`,来引用宿主 DOM 元素,",
+ "translation": "你可以在指令的构造函数中注入 `ElementRef`,来引用宿主 DOM 元素,",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
@@ -2486,17 +3426,17 @@
},
{
"original": "To use the new `HighlightDirective`, add a paragraph (`
`) element to the template of the root `AppComponent` and apply the directive as an attribute.",
- "translation": "运行应用,就会看到我们的指令确实高亮了段落中的文本。",
+ "translation": "要想使用这个新的 `HighlightDirective`,就往根组件 `AppComponent` 的模板中添加一个 `
` 元素,并把该指令作为一个属性使用。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Now run the application to see the `HighlightDirective` in action.",
- "translation": "运行这个应用以查看`HighlightDirective`的实际效果。",
+ "translation": "运行这个应用以查看 `HighlightDirective` 的实际效果。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "To summarize, Angular found the `appHighlight` attribute on the **host** `
` element.\nIt created an instance of the `HighlightDirective` class and\ninjected a reference to the `
` element into the directive's constructor\nwhich sets the `
` element's background style to yellow.",
- "translation": "总结:Angular 在**宿主**元素`
` 元素的背景设置为了黄色。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
@@ -2506,27 +3446,27 @@
},
{
"original": "Currently, `appHighlight` simply sets an element color.\nThe directive could be more dynamic.\nIt could detect when the user mouses into or out of the element\nand respond by setting or clearing the highlight color.",
- "translation": "当前,`appHighlight`只是简单的设置元素的颜色。\n这个指令应该在用户鼠标悬浮一个元素时,设置它的颜色。",
+ "translation": "当前,`appHighlight` 只是简单的设置元素的颜色。\n这个指令应该在用户鼠标悬浮一个元素时,设置它的颜色。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Begin by adding `HostListener` to the list of imported symbols.",
- "translation": "先把`HostListener`加进导入列表中,同时再添加`Input`符号,因为我们很快就要用到它。",
+ "translation": "先把 `HostListener` 加进导入列表中。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Then add two eventhandlers that respond when the mouse enters or leaves,\neach adorned by the `HostListener` decorator.",
- "translation": "然后使用`HostListener`装饰器添加两个事件处理器,它们会在鼠标进入或离开时进行响应。",
+ "translation": "然后使用 `HostListener` 装饰器添加两个事件处理器,它们会在鼠标进入或离开时进行响应。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "The `@HostListener` decorator lets you subscribe to events of the DOM\nelement that hosts an attribute directive, the `
` in this case.",
- "translation": "`@HostListener`装饰器引用属性型指令的宿主元素,在这个例子中就是`
`。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Of course you could reach into the DOM with standard JavaScript and attach event listeners manually.\nThere are at least three problems with _that_ approach:",
- "translation": "当然,你可以通过标准的JavaScript方式手动给宿主 DOM 元素附加一个事件监听器。\n但这种方法至少有三个问题:",
+ "translation": "当然,你可以通过标准的 JavaScript 方式手动给宿主 DOM 元素附加一个事件监听器。\n但这种方法至少有三个问题:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
@@ -2546,7 +3486,7 @@
},
{
"original": "The handlers delegate to a helper method that sets the color on the host DOM element, `el`.",
- "translation": "这些处理器委托了一个辅助方法来为DOM元素(`el`)设置颜色。",
+ "translation": "这些处理器委托了一个辅助方法来为 DOM 元素(`el`)设置颜色。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
@@ -2561,7 +3501,7 @@
},
{
"original": "Run the app and confirm that the background color appears when\nthe mouse hovers over the `p` and disappears as it moves out.",
- "translation": "运行本应用并确认:当把鼠标移到`p`上的时候,背景色就出现了,而移开的时候,它消失了。",
+ "translation": "运行本应用并确认:当把鼠标移到 `p` 上的时候,背景色就出现了,而移开的时候,它消失了。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
@@ -2571,42 +3511,42 @@
},
{
"original": "Currently the highlight color is hard-coded _within_ the directive. That's inflexible.\nIn this section, you give the developer the power to set the highlight color while applying the directive.",
- "translation": "高亮的颜色目前是硬编码在指令中的,这不够灵活。\n我们应该让指令的使用者可以指定要用哪种颜色进行高亮。",
+ "translation": "高亮的颜色目前是硬编码在指令中的,这不够灵活。\n在这一节中,你应该让指令的使用者可以指定要用哪种颜色进行高亮。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Begin by adding `Input` to the list of symbols imported from `@angular/core`.",
- "translation": "我们先从`@angular/core`中导入`Input`。",
+ "translation": "先从 `@angular/core` 中导入 `Input`。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Add a `highlightColor` property to the directive class like this:",
- "translation": "然后把`highlightColor`属性添加到指令类中,就像这样:",
+ "translation": "然后把 `highlightColor` 属性添加到指令类中,就像这样:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "### Binding to an _@Input_ property",
- "translation": "### 绑定到_@Input_属性",
+ "translation": "### 绑定到 *@Input* 属性",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Notice the `@Input` decorator. It adds metadata to the class that makes the directive's `highlightColor` property available for binding.",
- "translation": "注意看`@Input`装饰器。它往类上添加了一些元数据,从而让该指令的`highlightColor`能用于绑定。",
+ "translation": "注意看 `@Input` 装饰器。它往类上添加了一些元数据,从而让该指令的 `highlightColor` 能用于绑定。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "It's called an *input* property because data flows from the binding expression _into_ the directive.\nWithout that input metadata, Angular rejects the binding; see [below](guide/attribute-directives#why-input \"Why add @Input?\") for more about that.",
- "translation": "它之所以称为*输入*属性,是因为数据流是从绑定表达式流向指令内部的。\n如果没有这个元数据,Angular就会拒绝绑定,参见[稍后](guide/attribute-directives#why-input \"为什么要添加@Input?\")了解更多。",
+ "translation": "它之所以称为*输入*属性,是因为数据流是从绑定表达式流向指令内部的。\n如果没有这个元数据,Angular 就会拒绝绑定,参见[稍后](guide/attribute-directives#why-input \"为什么要添加@Input?\")了解更多。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Try it by adding the following directive binding variations to the `AppComponent` template:",
- "translation": "试试把下列指令绑定变量添加到`AppComponent`的模板中:",
+ "translation": "试试把下列指令绑定变量添加到 `AppComponent` 的模板中:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Add a `color` property to the `AppComponent`.",
- "translation": "把`color`属性添加到`AppComponent`中:",
+ "translation": "把 `color` 属性添加到 `AppComponent` 中:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
@@ -2616,42 +3556,42 @@
},
{
"original": "That's good, but it would be nice to _simultaneously_ apply the directive and set the color _in the same attribute_ like this.",
- "translation": "很不错,但还可以更好。我们可以在应用该指令时在同一个属性中设置颜色,就像这样:",
+ "translation": "很不错,但如果可以在应用该指令时在*同一个属性*中设置颜色就更好了,就像这样:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "The `[appHighlight]` attribute binding both applies the highlighting directive to the `
` element\nand sets the directive's highlight color with a property binding.\nYou're re-using the directive's attribute selector (`[appHighlight]`) to do both jobs.\nThat's a crisp, compact syntax.",
- "translation": "`[appHighlight]`属性同时做了两件事:把这个高亮指令应用到了`
` 元素上,并且通过属性绑定设置了该指令的高亮颜色。\n你复用了该指令的属性选择器 `[appHighlight]` 来同时完成它们。\n这是清爽、简约的语法。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "You'll have to rename the directive's `highlightColor` property to `appHighlight` because that's now the color property binding name.",
- "translation": "我们还要把该指令的`highlightColor`改名为`myHighlight`,因为它是颜色属性目前的绑定名。",
+ "translation": "你还要把该指令的 `highlightColor` 改名为 `myHighlight`,因为它是颜色属性目前的绑定名。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "This is disagreeable. The word, `appHighlight`, is a terrible property name and it doesn't convey the property's intent.",
- "translation": "这可不好。因为`appHighlight`是一个糟糕的属性名,而且不能反映该属性的意图。",
+ "translation": "这可不好。因为 `appHighlight` 是一个糟糕的属性名,而且不能反映该属性的意图。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "### Bind to an _@Input_ alias",
- "translation": "### 绑定到_@Input_别名",
+ "translation": "### 绑定到 *@Input* 别名",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Fortunately you can name the directive property whatever you want _and_ **_alias it_** for binding purposes.",
- "translation": "幸运的是,我们可以随意命名该指令的属性,并且**给它指定一个用于绑定的别名**。",
+ "translation": "幸运的是,你可以随意命名该指令的属性,并且**给它指定一个用于绑定的别名**。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Restore the original property name and specify the selector as the alias in the argument to `@Input`.",
- "translation": "恢复原始属性名,并在`@Input`的参数中把选择器`myHighlight`指定为别名。",
+ "translation": "恢复原始属性名,并在 `@Input` 的参数中把选择器 `myHighlight` 指定为别名。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "_Inside_ the directive the property is known as `highlightColor`.\n_Outside_ the directive, where you bind to it, it's known as `appHighlight`.",
- "translation": "在指令内部,该属性叫`highlightColor`,在外部,当我们绑定到它时,它叫`appHighlight`。",
+ "translation": "在指令内部,该属性叫 `highlightColor`,在外部,你绑定到它地方,它叫 `appHighlight`。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
@@ -2661,7 +3601,7 @@
},
{
"original": "Now that you're binding via the alias to the `highlightColor`, modify the `onMouseEnter()` method to use that property.\nIf someone neglects to bind to `appHighlightColor`, highlight the host element in red:",
- "translation": "现在,我们绑定到了`highlightColor`属性,并修改`onMouseEnter()`方法来使用它。\n如果有人忘了绑定到`appHighlightColor`,那就用红色进行高亮。",
+ "translation": "现在,你通过别名绑定到了 `highlightColor` 属性,并修改 `onMouseEnter()` 方法来使用它。\n如果有人忘了绑定到 `appHighlightColor`,那就用红色进行高亮。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
@@ -2676,17 +3616,17 @@
},
{
"original": "It may be difficult to imagine how this directive actually works.\nIn this section, you'll turn `AppComponent` into a harness that\nlets you pick the highlight color with a radio button and bind your color choice to the directive.",
- "translation": "凭空想象该指令如何工作可不容易。\n在本节,我们将把`AppComponent`改成一个测试程序,它让你可以通过单选按钮来选取高亮颜色,并且把你选取的颜色绑定到指令中。",
+ "translation": "凭空想象该指令如何工作可不容易。\n在本节,你将把 `AppComponent` 改成一个测试程序,它让你可以通过单选按钮来选取高亮颜色,并且把你选取的颜色绑定到指令中。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Update app.component.html as follows:",
- "translation": "把`app.component.html`修改成这样:",
+ "translation": "把 `app.component.html` 修改成这样:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Revise the `AppComponent.color` so that it has no initial value.",
- "translation": "修改`AppComponent.color`,让它不再有初始值。",
+ "translation": "修改 `AppComponent.color`,让它不再有初始值。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
@@ -2706,32 +3646,32 @@
},
{
"original": "At the moment, the default color—the color that prevails until\nthe user picks a highlight color—is hard-coded as \"red\".\nLet the template developer set the default color.",
- "translation": "目前,默认颜色(它在用户选取了高亮颜色之前一直有效)被硬编码为红色。我们要让模板的开发者也可以设置默认颜色。",
+ "translation": "目前,默认颜色(它在用户选取了高亮颜色之前一直有效)被硬编码为红色。应该允许模板的开发者设置默认颜色。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Add a second **input** property to `HighlightDirective` called `defaultColor`:",
- "translation": "把第二个名叫`defaultColor`的**输入**属性添加到`HighlightDirective`中:",
+ "translation": "把第二个名叫 `defaultColor` 的**输入**属性添加到 `HighlightDirective` 中:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Revise the directive's `onMouseEnter` so that it first tries to highlight with the `highlightColor`,\nthen with the `defaultColor`, and falls back to \"red\" if both properties are undefined.",
- "translation": "修改该指令的`onMouseEnter`,让它首先尝试使用`highlightColor`进行高亮,然后用`defaultColor`,如果它们都没有指定,那就用红色作为后备。",
+ "translation": "修改该指令的 `onMouseEnter`,让它首先尝试使用 `highlightColor` 进行高亮,然后用 `defaultColor`,如果它们都没有指定,那就用红色作为后备。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "How do you bind to a second property when you're already binding to the `appHighlight` attribute name?",
- "translation": "当已经绑定过`appHighlight`属性时,要如何绑定到第二个属性呢?",
+ "translation": "当已经绑定过 `appHighlight` 属性时,要如何绑定到第二个属性呢?",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "As with components, you can add as many directive property bindings as you need by stringing them along in the template.\nThe developer should be able to write the following template HTML to both bind to the `AppComponent.color`\nand fall back to \"violet\" as the default color.",
- "translation": "像组件一样,你也可以绑定到指令的很多属性,只要把它们依次写在模板中就行了。\n开发者可以绑定到`AppComponent.color`,并且用紫罗兰色作为默认颜色,代码如下:",
+ "translation": "像组件一样,你也可以绑定到指令的很多属性,只要把它们依次写在模板中就行了。\n开发者可以绑定到 `AppComponent.color`,并且用紫罗兰色作为默认颜色,代码如下:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "Angular knows that the `defaultColor` binding belongs to the `HighlightDirective`\nbecause you made it _public_ with the `@Input` decorator.",
- "translation": "Angular之所以知道`defaultColor`绑定属于`HighlightDirective`,是因为我们已经通过`@Input`装饰器把它设置成了*公共*属性。",
+ "translation": "Angular 之所以知道 `defaultColor` 绑定属于 `HighlightDirective`,是因为你已经通过 `@Input` 装饰器把它设置成了*公共*属性。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
@@ -2786,7 +3726,7 @@
},
{
"original": "In this demo, the `highlightColor` property is an ***input*** property of\nthe `HighlightDirective`. You've seen it applied without an alias:",
- "translation": "在这个例子中`hightlightColor`是`HighlightDirective`的一个***输入型***属性。我们见过它没有用别名时的代码:",
+ "translation": "在这个例子中 `hightlightColor` 是 `HighlightDirective` 的一个***输入型***属性。你见过它没有用别名时的代码:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
@@ -2796,37 +3736,37 @@
},
{
"original": "Either way, the `@Input` decorator tells Angular that this property is\n_public_ and available for binding by a parent component.\nWithout `@Input`, Angular refuses to bind to the property.",
- "translation": "无论哪种方式,`@Input`装饰器都告诉Angular,该属性是*公共的*,并且能被父组件绑定。\n如果没有`@Input`,Angular就会拒绝绑定到该属性。",
+ "translation": "无论哪种方式,`@Input` 装饰器都告诉 Angular,该属性是*公共的*,并且能被父组件绑定。\n如果没有 `@Input`,Angular 就会拒绝绑定到该属性。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "You've bound template HTML to component properties before and never used `@Input`.\nWhat's different?",
- "translation": "但我们以前也曾经把模板HTML绑定到组件的属性,而且从来没有用过`@Input`。\n差异何在?",
+ "translation": "但你以前也曾经把模板 HTML 绑定到组件的属性,而且从来没有用过 `@Input`。\n差异何在?",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "The difference is a matter of trust.\nAngular treats a component's template as _belonging_ to the component.\nThe component and its template trust each other implicitly.\nTherefore, the component's own template may bind to _any_ property of that component,\nwith or without the `@Input` decorator.",
- "translation": "差异在于信任度不同。\nAngular把组件的模板看做*从属于*该组件的。\n组件和它的模板默认会相互信任。\n这也就是意味着,组件自己的模板可以绑定到组件的*任意*属性,无论是否使用了`@Input`装饰器。",
+ "translation": "差异在于信任度不同。\nAngular 把组件的模板看做*从属于*该组件的。\n组件和它的模板默认会相互信任。\n这也就是意味着,组件自己的模板可以绑定到组件的*任意*属性,无论是否使用了 `@Input` 装饰器。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "But a component or directive shouldn't blindly trust _other_ components and directives.\nThe properties of a component or directive are hidden from binding by default.\nThey are _private_ from an Angular binding perspective.\nWhen adorned with the `@Input` decorator, the property becomes _public_ from an Angular binding perspective.\nOnly then can it be bound by some other component or directive.",
- "translation": "但组件或指令不应该盲目的信任其它组件或指令。\n因此组件或指令的属性默认是不能被绑定的。\n从Angular绑定机制的角度来看,它们是*私有*的,而当添加了`@Input`时,它们变成了*公共*的\n只有这样,它们才能被其它组件或属性绑定。",
+ "translation": "但组件或指令不应该盲目的信任其它组件或指令。\n因此组件或指令的属性默认是不能被绑定的。\n从 Angular 绑定机制的角度来看,它们是*私有*的,而当添加了 `@Input` 时,它们变成了*公共*的\n只有这样,它们才能被其它组件或属性绑定。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "You can tell if `@Input` is needed by the position of the property name in a binding.",
- "translation": "你可以根据属性名在绑定中出现的位置来判定是否要加`@Input`。",
+ "translation": "你可以根据属性名在绑定中出现的位置来判定是否要加 `@Input`。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "* When it appears in the template expression to the ***right*** of the equals (=),\n it belongs to the template's component and does not require the `@Input` decorator.",
- "translation": "当它出现在等号***右侧***的模板表达式中时,它属于模板所在的组件,不需要`@Input`装饰器。",
+ "translation": "当它出现在等号***右侧***的模板表达式中时,它属于模板所在的组件,不需要 `@Input` 装饰器。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "* When it appears in **square brackets** ([ ]) to the **left** of the equals (=),\n the property belongs to some _other_ component or directive;\n that property must be adorned with the `@Input` decorator.",
- "translation": "当它出现在等号**左边**的**方括号([ ])**中时,该属性属于*其它*组件或指令,它必须带有`@Input` 装饰器。",
+ "translation": "当它出现在等号**左边**的**方括号([ ])**中时,该属性属于*其它*组件或指令,它必须带有 `@Input` 装饰器。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
@@ -2836,12 +3776,12 @@
},
{
"original": "* The `color` property in the expression on the right belongs to the template's component.\n The template and its component trust each other.\n The `color` property doesn't require the `@Input` decorator.",
- "translation": "`color`属性位于右侧的绑定表达式中,它属于模板所在的组件。\n 该模板和组件相互信任。因此`color`不需要`@Input`装饰器。",
+ "translation": "`color` 属性位于右侧的绑定表达式中,它属于模板所在的组件。\n 该模板和组件相互信任。因此 `color` 不需要 `@Input` 装饰器。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
"original": "* The `appHighlight` property on the left refers to an _aliased_ property of the `HighlightDirective`,\n not a property of the template's component. There are trust issues.\n Therefore, the directive property must carry the `@Input` decorator.",
- "translation": "`appHighlight`属性位于左侧,它引用了`HighlightDirective`中一个*带别名的*属性,它不是模板所属组件的一部分,因此存在信任问题。\n所以,该属性必须带`@Input`装饰器。",
+ "translation": "`appHighlight` 属性位于左侧,它引用了 `HighlightDirective` 中一个*带别名的*属性,它不是模板所属组件的一部分,因此存在信任问题。\n所以,该属性必须带 `@Input` 装饰器。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/attribute-directives.md"
},
{
@@ -2901,7 +3841,7 @@
},
{
"original": "* **_bootstrap_**—the _root_ component that Angular creates and inserts\ninto the `index.html` host web page.",
- "translation": "**_bootstrap_** —— *根*组件,Angular 创建它并插入`index.html`宿主页面。",
+ "translation": "**_bootstrap_** —— *根*组件,Angular 创建它并插入 `index.html` 宿主页面。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/bootstrapping.md"
},
{
@@ -3056,7 +3996,7 @@
},
{
"original": "## More about Angular Modules",
- "translation": "## 关于Angular模块的更多知识",
+ "translation": "## 关于 Angular 模块的更多知识",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/bootstrapping.md"
},
{
@@ -3126,7 +4066,7 @@
},
{
"original": "You compensate by loading polyfill scripts (\"polyfills\") for the browsers that you must support.\nThe [table below](#polyfill-libs) identifies most of the polyfills you might need.",
- "translation": "我们可以通过加载腻子脚本(\"polyfills\")来为想要支持的浏览器弥补这些特性。\n[下表](#polyfill-libs) 列出了可能用到的大多数腻子脚本。",
+ "translation": "你可以通过加载腻子脚本(\"polyfills\")来为想要支持的浏览器弥补这些特性。\n[下表](#polyfill-libs) 列出了可能用到的大多数腻子脚本。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/browser-support.md"
},
{
@@ -3151,7 +4091,7 @@
},
{
"original": "The npm packages for the _mandatory_ polyfills (such as `zone.js`) were installed automatically for you when you created your project and their corresponding `import` statements are ready to go. You probably won't touch these.",
- "translation": "**强制性** 腻子脚本(如`zone.js`)的npm 包在创建项目时就已经自动安装了,相应的 `import` 语句也都加好了。我们一般不用动它们。",
+ "translation": "**强制性** 腻子脚本(如 `zone.js`)的 npm 包在创建项目时就已经自动安装了,相应的 `import` 语句也都加好了。你一般不用动它们。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/browser-support.md"
},
{
@@ -3204,6 +4144,11 @@
"translation": "需要的腻子脚本",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/browser-support.md"
},
+ {
+ "original": "[ES7/reflect](guide/browser-support#core-es7-reflect) (JIT only)",
+ "translation": "[ES7/reflect](guide/browser-support#core-es7-reflect) (仅 JIT)",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/browser-support.md"
+ },
{
"original": "### Optional browser features to polyfill",
"translation": "### 可选浏览器特性的腻子脚本",
@@ -3266,12 +4211,12 @@
},
{
"original": "
If AnimationBuilder is used then the polyfill will enable scrubbing\n support for IE/Edge and Safari (Chrome and Firefox support this natively).
",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/cheatsheet.md"
},
+ {
+ "original": "# Observables compared to other techniques",
+ "translation": "# 可观察对象与其它技术的比较",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "You can often use observables instead of promises to deliver values asynchronously. Similarly, observables can take the place of event handlers. Finally, because observables deliver multiple values, you can use them where you might otherwise build and operate on arrays.",
+ "translation": "你可以经常使用可观察对象(Observable)而不是承诺(Promise)来异步传递值。\n类似的,可观察对象也可以取代事件处理器的位置。最后,由于可观察对象传递多个值,所以你可以在任何可能构建和操作数组的地方使用可观察对象。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Observables behave somewhat differently from the alternative techniques in each of these situations, but offer some significant advantages. Here are detailed comparisons of the differences.",
+ "translation": "在这些情况下,可观察对象的行为与其替代技术有一些差异,不过也提供了一些显著的优势。下面是对这些差异的详细比较。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "## Observables compared to promises",
+ "translation": "## 可观察对象 vs. 承诺",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Observables are often compared to promises. Here are some key differences:",
+ "translation": "可观察对象经常拿来和承诺进行对比。有一些关键的不同点:",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "* 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.",
+ "translation": "可观察对象是声明式的,在被订阅之前,它不会开始执行。承诺是在创建时就立即执行的。这让可观察对象可用于定义那些应该按需执行的菜谱。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "* Observables provide many values. Promises provide one. This makes observables useful for getting multiple values over time.",
+ "translation": "可观察对象能提供多个值。承诺只提供一个。这让可观察对象可用于随着时间的推移获取多个值。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "* 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.",
+ "translation": "可观察对象会区分串联处理和订阅语句。承诺只有 `.then()` 语句。这让可观察对象可用于创建供系统的其它部分使用而不希望立即执行的复杂菜谱。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "* Observables `subscribe()` is responsible for handling errors. Promises push errors to the child promises. This makes observables useful for centralized and predictable error handling.",
+ "translation": "可观察对象的 `subscribe()` 会负责处理错误。承诺会把错误推送给它的子承诺。这让可观察对象可用于进行集中式、可预测的错误处理。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "### Creation and subscription",
+ "translation": "### 创建与订阅",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "* 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.",
+ "translation": "在有消费者订阅之前,可观察对象不会执行。`subscribe()` 会执行一次定义好的行为,并且可以再次调用它。每次订阅都是单独计算的。重新订阅会导致重新计算这些值。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "* 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.",
+ "translation": "承诺会立即执行,并且只执行一次。当承诺创建时,会立即计算出结果。没有办法重新做一次。所有的 `then` 语句(订阅)都会共享同一次计算。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "### Chaining",
+ "translation": "### 串联",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "* Observables differentiate between transformation function such as a map and subscription. Only subscription activates the subscriber function to start computing the values.",
+ "translation": "可观察对象会区分各种转换函数,比如映射和订阅。只有订阅才会激活订阅者函数,以开始计算那些值。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "* Promises do not differentiate between the last `.then` clauses (equivalent to subscription) and intermediate `.then` clauses (equivalent to map).",
+ "translation": "承诺并不区分最后的 `.then()` 语句(等价于订阅)和中间的 `.then()` 语句(等价于映射)。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "### Cancellation",
+ "translation": "### 可取消",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "* Observable subscriptions are cancellable. Unsubscribing removes the listener from receiving further values, and notifies the subscriber function to cancel work.",
+ "translation": "可观察对象的订阅是可取消的。取消订阅会移除监听器,使其不再接受将来的值,并通知订阅者函数取消正在进行的工作。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "* Promises are not cancellable.",
+ "translation": "承诺是不可取消的。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
{
"original": "### Error handling",
"translation": "### 错误处理",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
},
+ {
+ "original": "* Observable execution errors are delivered to the subscriber's error handler, and the subscriber automatically unsubscribes from the observable.",
+ "translation": "可观察对象的错误处理是交给订阅者的错误处理器的,并且该订阅者会自动取消对这个可观察对象的订阅。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "* Promises push errors to the child promises.",
+ "translation": "承诺会把错误推给其子承诺。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "### Cheat sheet",
+ "translation": "### 速查表",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "The following code snippets illustrate how the same kind of operation is defined using observables and promises.",
+ "translation": "下列代码片段揭示了同样的操作要如何分别使用可观察对象和承诺进行实现。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Operation",
+ "translation": "操作",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Observable",
+ "translation": "可观察对象",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Promise",
+ "translation": "承诺",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Creation",
+ "translation": "创建",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Transform",
+ "translation": "转换",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Subscribe",
+ "translation": "订阅",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Unsubscribe",
+ "translation": "取消订阅",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Implied by promise resolution.",
+ "translation": "承诺被解析时隐式完成。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "## Observables compared to events API",
+ "translation": "## 可观察对象 vs. 事件 API",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Observables are very similar to event handlers that use the events API. Both techniques define notification handlers, and use them to process multiple values delivered over time. Subscribing to an observable is equivalent to adding an event listener. One significant difference is that you can configure an observable to transform an event before passing the event to the handler.",
+ "translation": "可观察对象和事件 API 中的事件处理器很像。这两种技术都会定义通知处理器,并使用它们来处理一段时间内传递的多个值。订阅可观察对象与添加事件处理器是等价的。一个显著的不同是你可以配置可观察对象,使其在把事件传给事件处理器之间先进行转换。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Using observables to handle events and asynchronous operations can have the advantage of greater consistency in contexts such as HTTP requests.",
+ "translation": "使用可观察对象来处理错误和异步操作在 HTTP 请求这样的场景下更加具有一致性。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Here are some code samples that illustrate how the same kind of operation is defined using observables and the events API.",
+ "translation": "下列代码片段揭示了同样的操作要如何分别使用可观察对象和事件 API 进行实现。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Observable",
+ "translation": "可观察对象",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Events API",
+ "translation": "事件 API",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Creation & cancellation",
+ "translation": "创建与取消",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Subscription",
+ "translation": "订阅",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Configuration",
+ "translation": "配置",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Listen for keystrokes, but provide a stream representing the value in the input.",
+ "translation": "监听按键,提供一个流来表示这些输入的值。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Does not support configuration.",
+ "translation": "不支持配置。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "## Observables compared to arrays",
+ "translation": "## 可观察对象 vs. 数组",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "An observable produces values over time. An array is created as a static set of values. In a sense, observables are asynchronous where arrays are synchronous. In the following examples, ➞ implies asynchronous value delivery.",
+ "translation": "可观察对象会随时间生成值。数组是用一组静态的值创建的。某种意义上,可观察对象是异步的,而数组是同步的。\n在下列例子中,➞ 符号表示异步传递值。",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Observable",
+ "translation": "可观察对象",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Array",
+ "translation": "数组",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
+ {
+ "original": "Given",
+ "translation": "给出值",
+ "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/comparing-observables.md"
+ },
{
"original": "# Component Interaction",
"translation": "# 组件之间的交互",
@@ -4176,12 +5351,12 @@
},
{
"original": "* [Intercept input property changes with `ngOnChanges()`](guide/component-interaction#parent-to-child-on-changes)",
- "translation": "[使用`ngOnChanges()`拦截输入属性的变化](guide/component-interaction#parent-to-child-on-changes)",
+ "translation": "[使用 `ngOnChanges()` 拦截输入属性的变化](guide/component-interaction#parent-to-child-on-changes)",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "* [Parent calls an `@ViewChild()`](guide/component-interaction#parent-to-view-child)",
- "translation": "[在父组件中调用`@ViewChild()`](guide/component-interaction#parent-to-view-child)",
+ "translation": "[在父组件中调用 `@ViewChild()`](guide/component-interaction#parent-to-view-child)",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4201,17 +5376,17 @@
},
{
"original": "`HeroChildComponent` has two ***input properties***,\ntypically adorned with [@Input decorations](guide/template-syntax#inputs-outputs).",
- "translation": "`HeroChildComponent` 有两个***输入型属性***,它们通常带[@Input装饰器](guide/template-syntax#inputs-outputs)。",
+ "translation": "`HeroChildComponent` 有两个***输入型属性***,它们通常带[@Input 装饰器](guide/template-syntax#inputs-outputs)。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "The second `@Input` aliases the child component property name `masterName` as `'master'`.",
- "translation": "第二个`@Input`为子组件的属性名`masterName`指定一个别名`master`(译者注:不推荐为起别名,请参见风格指南).",
+ "translation": "第二个 `@Input` 为子组件的属性名 `masterName` 指定一个别名 `master`(译者注:不推荐为起别名,请参见风格指南).",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "The `HeroParentComponent` nests the child `HeroChildComponent` inside an `*ngFor` repeater,\nbinding its `master` string property to the child's `master` alias,\nand each iteration's `hero` instance to the child's `hero` property.",
- "translation": "父组件`HeroParentComponent`把子组件的`HeroChildComponent`放到`*ngFor`循环器中,把自己的`master`字符串属性绑定到子组件的`master`别名上,并把每个循环的`hero`实例绑定到子组件的`hero`属性。",
+ "translation": "父组件 `HeroParentComponent` 把子组件的 `HeroChildComponent` 放到 `*ngFor` 循环器中,把自己的 `master` 字符串属性绑定到子组件的 `master` 别名上,并把每个循环的 `hero` 实例绑定到子组件的 `hero` 属性。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4236,22 +5411,22 @@
},
{
"original": "## Intercept input property changes with a setter",
- "translation": "## 通过setter截听输入属性值的变化",
+ "translation": "## 通过 setter 截听输入属性值的变化",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "Use an input property setter to intercept and act upon a value from the parent.",
- "translation": "使用一个输入属性的setter,以拦截父组件中值的变化,并采取行动。",
+ "translation": "使用一个输入属性的 setter,以拦截父组件中值的变化,并采取行动。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "The setter of the `name` input property in the child `NameChildComponent`\ntrims the whitespace from a name and replaces an empty value with default text.",
- "translation": "子组件`NameChildComponent`的输入属性`name`上的这个setter,会trim掉名字里的空格,并把空值替换成默认字符串。",
+ "translation": "子组件 `NameChildComponent` 的输入属性 `name` 上的这个 setter,会 trim 掉名字里的空格,并把空值替换成默认字符串。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "Here's the `NameParentComponent` demonstrating name variations including a name with all spaces:",
- "translation": "下面的`NameParentComponent`展示了各种名字的处理方式,包括一个全是空格的名字。",
+ "translation": "下面的 `NameParentComponent` 展示了各种名字的处理方式,包括一个全是空格的名字。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4261,7 +5436,7 @@
},
{
"original": "E2E tests of input property setter with empty and non-empty names:",
- "translation": "端到端测试:输入属性的setter,分别使用空名字和非空名字。",
+ "translation": "端到端测试:输入属性的 setter,分别使用空名字和非空名字。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4276,27 +5451,27 @@
},
{
"original": "Detect and act upon changes to input property values with the `ngOnChanges()` method of the `OnChanges` lifecycle hook interface.",
- "translation": "使用`OnChanges`生命周期钩子接口的`ngOnChanges()`方法来监测输入属性值的变化并做出回应。",
+ "translation": "使用 `OnChanges` 生命周期钩子接口的 `ngOnChanges()` 方法来监测输入属性值的变化并做出回应。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "You may prefer this approach to the property setter when watching multiple, interacting input properties.",
- "translation": "当需要监视多个、交互式输入属性的时候,本方法比用属性的setter更合适。",
+ "translation": "当需要监视多个、交互式输入属性的时候,本方法比用属性的 setter 更合适。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "Learn about `ngOnChanges()` in the [LifeCycle Hooks](guide/lifecycle-hooks) chapter.",
- "translation": "学习关于`ngOnChanges()`的更多知识,参见[生命周期钩子](guide/lifecycle-hooks)一章。",
+ "translation": "学习关于 `ngOnChanges()` 的更多知识,参见[生命周期钩子](guide/lifecycle-hooks)一章。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "This `VersionChildComponent` detects changes to the `major` and `minor` input properties and composes a log message reporting these changes:",
- "translation": "这个`VersionChildComponent`会监测输入属性`major`和`minor`的变化,并把这些变化编写成日志以报告这些变化。",
+ "translation": "这个 `VersionChildComponent` 会监测输入属性 `major` 和 `minor` 的变化,并把这些变化编写成日志以报告这些变化。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "The `VersionParentComponent` supplies the `minor` and `major` values and binds buttons to methods that change them.",
- "translation": "`VersionParentComponent`提供`minor`和`major`值,把修改它们值的方法绑定到按钮上。",
+ "translation": "`VersionParentComponent` 提供 `minor` 和 `major` 值,把修改它们值的方法绑定到按钮上。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4311,7 +5486,7 @@
},
{
"original": "Test that ***both*** input properties are set initially and that button clicks trigger\nthe expected `ngOnChanges` calls and values:",
- "translation": "测试确保***这两个***输入属性值都被初始化了,当点击按钮后,`ngOnChanges`应该被调用,属性的值也符合预期。",
+ "translation": "测试确保***这两个***输入属性值都被初始化了,当点击按钮后,`ngOnChanges` 应该被调用,属性的值也符合预期。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4326,27 +5501,27 @@
},
{
"original": "The child component exposes an `EventEmitter` property with which it `emits` events when something happens.\nThe parent binds to that event property and reacts to those events.",
- "translation": "子组件暴露一个`EventEmitter`属性,当事件发生时,子组件利用该属性`emits`(向上弹射)事件。父组件绑定到这个事件属性,并在事件发生时作出回应。",
+ "translation": "子组件暴露一个 `EventEmitter` 属性,当事件发生时,子组件利用该属性 `emits`(向上弹射)事件。父组件绑定到这个事件属性,并在事件发生时作出回应。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "The child's `EventEmitter` property is an ***output property***,\n typically adorned with an [@Output decoration](guide/template-syntax#inputs-outputs)\n as seen in this `VoterComponent`:",
- "translation": "子组件的`EventEmitter`属性是一个**输出属性**,通常带有[@Output装饰器](guide/template-syntax#inputs-outputs),就像在`VoterComponent`中看到的。",
+ "translation": "子组件的 `EventEmitter` 属性是一个**输出属性**,通常带有[@Output 装饰器](guide/template-syntax#inputs-outputs),就像在 `VoterComponent` 中看到的。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "Clicking a button triggers emission of a `true` or `false`, the boolean *payload*.",
- "translation": "点击按钮会触发`true`或`false`(布尔型*有效载荷*)的事件。",
+ "translation": "点击按钮会触发 `true` 或 `false`(布尔型*有效载荷*)的事件。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "The parent `VoteTakerComponent` binds an event handler called `onVoted()` that responds to the child event\npayload `$event` and updates a counter.",
- "translation": "父组件`VoteTakerComponent`绑定了一个事件处理器(`onVoted()`),用来响应子组件的事件(`$event`)并更新一个计数器。",
+ "translation": "父组件 `VoteTakerComponent` 绑定了一个事件处理器(`onVoted()`),用来响应子组件的事件(`$event`)并更新一个计数器。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "The framework passes the event argument—represented by `$event`—to the handler method,\nand the method processes it:",
- "translation": "框架(Angular)把事件参数(用`$event`表示)传给事件处理方法,这个方法会处理:",
+ "translation": "框架(Angular)把事件参数(用 `$event` 表示)传给事件处理方法,这个方法会处理:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4356,7 +5531,7 @@
},
{
"original": "Test that clicking the *Agree* and *Disagree* buttons update the appropriate counters:",
- "translation": "测试确保点击*Agree*和*Disagree*按钮时,计数器被正确更新。",
+ "translation": "测试确保点击 *Agree* 和 *Disagree* 按钮时,计数器被正确更新。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4376,17 +5551,17 @@
},
{
"original": "The following is a child `CountdownTimerComponent` that repeatedly counts down to zero and launches a rocket.\nIt has `start` and `stop` methods that control the clock and it displays a\ncountdown status message in its own template.",
- "translation": "子组件`CountdownTimerComponent`进行倒计时,归零时发射一个导弹。`start`和`stop`方法负责控制时钟并在模板里显示倒计时的状态信息。",
+ "translation": "子组件 `CountdownTimerComponent` 进行倒计时,归零时发射一个导弹。`start` 和 `stop` 方法负责控制时钟并在模板里显示倒计时的状态信息。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "The `CountdownLocalVarParentComponent` that hosts the timer component is as follows:",
- "translation": "让我们来看看计时器组件的宿主组件`CountdownLocalVarParentComponent`。",
+ "translation": "计时器组件的宿主组件 `CountdownLocalVarParentComponent` 如下:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "The parent component cannot data bind to the child's\n`start` and `stop` methods nor to its `seconds` property.",
- "translation": "父组件不能通过数据绑定使用子组件的`start`和`stop`方法,也不能访问子组件的`seconds`属性。",
+ "translation": "父组件不能通过数据绑定使用子组件的 `start` 和 `stop` 方法,也不能访问子组件的 `seconds` 属性。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4396,7 +5571,7 @@
},
{
"original": "This example wires parent buttons to the child's `start` and `stop` and\nuses interpolation to display the child's `seconds` property.",
- "translation": "在这个例子中,我们把父组件的按钮绑定到子组件的`start`和`stop`方法,并用插值表达式来显示子组件的`seconds`属性。",
+ "translation": "这个例子把父组件的按钮绑定到子组件的 `start` 和 `stop` 方法,并用插值表达式来显示子组件的 `seconds` 属性。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4411,7 +5586,7 @@
},
{
"original": "Test that the seconds displayed in the parent template\nmatch the seconds displayed in the child's status message.\nTest also that clicking the *Stop* button pauses the countdown timer:",
- "translation": "测试确保在父组件模板中显示的秒数和子组件状态信息里的秒数同步。它还会点击*Stop*按钮来停止倒计时:",
+ "translation": "测试确保在父组件模板中显示的秒数和子组件状态信息里的秒数同步。它还会点击 *Stop* 按钮来停止倒计时:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4436,22 +5611,22 @@
},
{
"original": "When the parent component *class* requires that kind of access,\n***inject*** the child component into the parent as a *ViewChild*.",
- "translation": "当父组件*类*需要这种访问时,可以把子组件作为*ViewChild*,***注入***到父组件里面。",
+ "translation": "当父组件*类*需要这种访问时,可以把子组件作为 *ViewChild*,***注入***到父组件里面。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "The following example illustrates this technique with the same\n[Countdown Timer](guide/component-interaction#countdown-timer-example) example.\nNeither its appearance nor its behavior will change.\nThe child [CountdownTimerComponent](guide/component-interaction#countdown-timer-example) is the same as well.",
- "translation": "下面的例子用与[倒计时](guide/component-interaction#countdown-timer-example)相同的范例来解释这种技术。\n我们没有改变它的外观或行为。子组件[CountdownTimerComponent](guide/component-interaction#countdown-timer-example)也和原来一样。",
+ "translation": "下面的例子用与[倒计时](guide/component-interaction#countdown-timer-example)相同的范例来解释这种技术。\n它的外观或行为没有变化。子组件[CountdownTimerComponent](guide/component-interaction#countdown-timer-example)也和原来一样。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "The switch from the *local variable* to the *ViewChild* technique\nis solely for the purpose of demonstration.",
- "translation": "由*本地变量*切换到*ViewChild*技术的唯一目的就是做示范。",
+ "translation": "由*本地变量*切换到 *ViewChild* 技术的唯一目的就是做示范。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "Here is the parent, `CountdownViewChildParentComponent`:",
- "translation": "下面是父组件`CountdownViewChildParentComponent`:",
+ "translation": "下面是父组件 `CountdownViewChildParentComponent`:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4461,17 +5636,17 @@
},
{
"original": "First, you have to import references to the `ViewChild` decorator and the `AfterViewInit` lifecycle hook.",
- "translation": "首先,你要使用`ViewChild`装饰器导入这个引用,并挂上`AfterViewInit`生命周期钩子。",
+ "translation": "首先,你要使用 `ViewChild` 装饰器导入这个引用,并挂上 `AfterViewInit` 生命周期钩子。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "Next, inject the child `CountdownTimerComponent` into the private `timerComponent` property\nvia the `@ViewChild` property decoration.",
- "translation": "接着,通过`@ViewChild`属性装饰器,将子组件`CountdownTimerComponent`注入到私有属性`timerComponent`里面。",
+ "translation": "接着,通过 `@ViewChild` 属性装饰器,将子组件 `CountdownTimerComponent` 注入到私有属性 `timerComponent` 里面。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "The `#timer` local variable is gone from the component metadata.\nInstead, bind the buttons to the parent component's own `start` and `stop` methods and\npresent the ticking seconds in an interpolation around the parent component's `seconds` method.",
- "translation": "组件元数据里就不再需要`#timer`本地变量了。而是把按钮绑定到父组件自己的`start`和`stop`方法,使用父组件的`seconds`方法的插值表达式来展示秒数变化。",
+ "translation": "组件元数据里就不再需要 `#timer` 本地变量了。而是把按钮绑定到父组件自己的 `start` 和 `stop` 方法,使用父组件的 `seconds` 方法的插值表达式来展示秒数变化。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4481,17 +5656,17 @@
},
{
"original": "The `ngAfterViewInit()` lifecycle hook is an important wrinkle.\nThe timer component isn't available until *after* Angular displays the parent view.\nSo it displays `0` seconds initially.",
- "translation": "`ngAfterViewInit()`生命周期钩子是非常重要的一步。被注入的计时器组件只有在Angular显示了父组件视图之后才能访问,所以我们先把秒数显示为0.",
+ "translation": "`ngAfterViewInit()` 生命周期钩子是非常重要的一步。被注入的计时器组件只有在 Angular 显示了父组件视图之后才能访问,所以它先把秒数显示为 0.",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "Then Angular calls the `ngAfterViewInit` lifecycle hook at which time it is *too late*\nto update the parent view's display of the countdown seconds.\nAngular's unidirectional data flow rule prevents updating the parent view's\nin the same cycle. The app has to *wait one turn* before it can display the seconds.",
- "translation": "然后Angular会调用`ngAfterViewInit`生命周期钩子,但这时候再更新父组件视图的倒计时就已经太晚了。Angular的单向数据流规则会阻止在同一个周期内更新父组件视图。我们在显示秒数之前会被迫*再等一轮*。",
+ "translation": "然后 Angular 会调用 `ngAfterViewInit` 生命周期钩子,但这时候再更新父组件视图的倒计时就已经太晚了。Angular 的单向数据流规则会阻止在同一个周期内更新父组件视图。应用在显示秒数之前会被迫*再等一轮*。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "Use `setTimeout()` to wait one tick and then revise the `seconds()` method so\nthat it takes future values from the timer component.",
- "translation": "使用`setTimeout()`来等下一轮,然后改写`seconds()`方法,这样它接下来就会从注入的这个计时器组件里获取秒数的值。",
+ "translation": "使用 `setTimeout()` 来等下一轮,然后改写 `seconds()` 方法,这样它接下来就会从注入的这个计时器组件里获取秒数的值。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4526,32 +5701,32 @@
},
{
"original": "This `MissionService` connects the `MissionControlComponent` to multiple `AstronautComponent` children.",
- "translation": "这个`MissionService`把`MissionControlComponent`和多个`AstronautComponent`子组件连接起来。",
+ "translation": "这个 `MissionService` 把 `MissionControlComponent` 和多个 `AstronautComponent` 子组件连接起来。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "The `MissionControlComponent` both provides the instance of the service that it shares with its children\n(through the `providers` metadata array) and injects that instance into itself through its constructor:",
- "translation": "`MissionControlComponent`提供服务的实例,并将其共享给它的子组件(通过`providers`元数据数组),子组件可以通过构造函数将该实例注入到自身。",
+ "translation": "`MissionControlComponent` 提供服务的实例,并将其共享给它的子组件(通过 `providers` 元数据数组),子组件可以通过构造函数将该实例注入到自身。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "The `AstronautComponent` also injects the service in its constructor.\nEach `AstronautComponent` is a child of the `MissionControlComponent` and therefore receives its parent's service instance:",
- "translation": "`AstronautComponent`也通过自己的构造函数注入该服务。由于每个`AstronautComponent`都是`MissionControlComponent`的子组件,所以它们获取到的也是父组件的这个服务实例。",
+ "translation": "`AstronautComponent` 也通过自己的构造函数注入该服务。由于每个 `AstronautComponent` 都是 `MissionControlComponent` 的子组件,所以它们获取到的也是父组件的这个服务实例。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "Notice that this example captures the `subscription` and `unsubscribe()` when the `AstronautComponent` is destroyed.\nThis is a memory-leak guard step. There is no actual risk in this app because the\nlifetime of a `AstronautComponent` is the same as the lifetime of the app itself.\nThat *would not* always be true in a more complex application.",
- "translation": "注意,这个例子保存了`subscription`变量,并在`AstronautComponent`被销毁时调用`unsubscribe()`退订。\n这是一个用于防止内存泄漏的保护措施。实际上,在这个应用程序中并没有这个风险,因为`AstronautComponent`的生命期和应用程序的生命期一样长。但在更复杂的应用程序环境中就不一定了。",
+ "translation": "注意,这个例子保存了 `subscription` 变量,并在 `AstronautComponent` 被销毁时调用 `unsubscribe()` 退订。\n这是一个用于防止内存泄漏的保护措施。实际上,在这个应用程序中并没有这个风险,因为 `AstronautComponent` 的生命期和应用程序的生命期一样长。但在更复杂的应用程序环境中就不一定了。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "You don't add this guard to the `MissionControlComponent` because, as the parent,\nit controls the lifetime of the `MissionService`.",
- "translation": "不需要在`MissionControlComponent`中添加这个保护措施,因为它作为父组件,控制着`MissionService`的生命期。",
+ "translation": "不需要在 `MissionControlComponent` 中添加这个保护措施,因为它作为父组件,控制着 `MissionService` 的生命期。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
"original": "The *History* log demonstrates that messages travel in both directions between\nthe parent `MissionControlComponent` and the `AstronautComponent` children,\nfacilitated by the service:",
- "translation": "*History*日志证明了:在父组件`MissionControlComponent`和子组件`AstronautComponent`之间,信息通过该服务实现了双向传递。",
+ "translation": "*History* 日志证明了:在父组件 `MissionControlComponent` 和子组件 `AstronautComponent` 之间,信息通过该服务实现了双向传递。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4561,7 +5736,7 @@
},
{
"original": "Tests click buttons of both the parent `MissionControlComponent` and the `AstronautComponent` children\nand verify that the history meets expectations:",
- "translation": "测试确保点击父组件`MissionControlComponent`和子组件`AstronautComponent`两个的组件的按钮时,*History*日志和预期的一样。",
+ "translation": "测试确保点击父组件 `MissionControlComponent` 和子组件 `AstronautComponent` 两个的组件的按钮时,*History* 日志和预期的一样。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-interaction.md"
},
{
@@ -4576,22 +5751,22 @@
},
{
"original": "Angular applications are styled with standard CSS. That means you can apply\neverything you know about CSS stylesheets, selectors, rules, and media queries\ndirectly to Angular applications.",
- "translation": "Angular 应用使用标准的 CSS 来设置样式。这意味着我们可以把关于 CSS\n的那些知识和技能直接用于我们的 Angular 程序中,例如:样式表、选择器、规则以及媒体查询等。",
+ "translation": "Angular 应用使用标准的 CSS 来设置样式。这意味着你可以把关于 CSS\n的那些知识和技能直接用于 Angular 程序中,例如:样式表、选择器、规则以及媒体查询等。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "Additionally, Angular can bundle *component styles*\nwith components, enabling a more modular design than regular stylesheets.",
- "translation": "另外,Angular 还能把*组件样式*捆绑在我们的组件上,以实现比标准样式表更加模块化的设计。",
+ "translation": "另外,Angular 还能把*组件样式*捆绑在组件上,以实现比标准样式表更加模块化的设计。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "This page describes how to load and apply these component styles.",
- "translation": "在本章中,我们将学到如何加载和使用这些*组件样式*。",
+ "translation": "本章将会讲解如何加载和使用这些*组件样式*。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "You can run the in Stackblitz and download the code from there.",
- "translation": "运行来试用本页的代码。",
+ "translation": "你可以运行来在 Stackblitz 中试用并下载本页的代码。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
@@ -4601,12 +5776,12 @@
},
{
"original": "For every Angular component you write, you may define not only an HTML template,\nbut also the CSS styles that go with that template,\nspecifying any selectors, rules, and media queries that you need.",
- "translation": "对于我们写的每个 Angular 组件来说,除了定义 HTML 模板之外,我们还要定义用于模板的 CSS 样式、\n指定任意的选择器、规则和媒体查询。",
+ "translation": "对你编写的每个 Angular 组件来说,除了定义 HTML 模板之外,还要定义用于模板的 CSS 样式、\n指定任意的选择器、规则和媒体查询。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "One way to do this is to set the `styles` property in the component metadata.\nThe `styles` property takes an array of strings that contain CSS code.\nUsually you give it one string, as in the following example:",
- "translation": "实现方式之一,是在组件的元数据中设置`styles`属性。\n`styles`属性可以接受一个包含 CSS 代码的字符串数组。\n通常我们只给它一个字符串就行了,如同下例:",
+ "translation": "实现方式之一,是在组件的元数据中设置 `styles` 属性。\n`styles` 属性可以接受一个包含 CSS 代码的字符串数组。\n通常你只给它一个字符串就行了,如同下例:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
@@ -4646,17 +5821,17 @@
},
{
"original": "* Changes to styles elsewhere in the application don't affect the component's styles.",
- "translation": "我们组件的样式*不会*因为别的地方修改了样式而被意外改变。",
+ "translation": "组件的样式*不会*因为别的地方修改了样式而被意外改变。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "* You can co-locate the CSS code of each component with the TypeScript and HTML code of the component,\n which leads to a neat and tidy project structure.",
- "translation": "我们可以让每个组件的 CSS 代码和它的 TypeScript、HTML 代码放在一起,这将促成清爽整洁的项目结构。",
+ "translation": "你可以让每个组件的 CSS 代码和它的 TypeScript、HTML 代码放在一起,这将促成清爽整洁的项目结构。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "* You can change or remove component CSS code without searching through the\n whole application to find where else the code is used.",
- "translation": "将来我们可以修改或移除组件的 CSS 代码,而不用遍历整个应用来看它有没有被别处用到,只要看看当前组件就可以了。",
+ "translation": "将来你可以修改或移除组件的 CSS 代码,而不用遍历整个应用来看它有没有被别处用到,只要看看当前组件就可以了。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
@@ -4676,22 +5851,22 @@
},
{
"original": "Use the `:host` pseudo-class selector to target styles in the element that *hosts* the component (as opposed to\ntargeting elements *inside* the component's template).",
- "translation": "使用`:host`伪类选择器,用来选择组件*宿主*元素中的元素(相对于组件模板*内部*的元素)。",
+ "translation": "使用 `:host` 伪类选择器,用来选择组件*宿主*元素中的元素(相对于组件模板*内部*的元素)。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "The `:host` selector is the only way to target the host element. You can't reach\nthe host element from inside the component with other selectors because it's not part of the\ncomponent's own template. The host element is in a parent component's template.",
- "translation": "这是我们能以宿主元素为目标的*唯一*方式。除此之外,我们将没办法指定它,\n因为宿主不是组件自身模板的一部分,而是父组件模板的一部分。",
+ "translation": "`:host` 选择是是把宿主元素作为目标的*唯一*方式。除此之外,你将没办法指定它,\n因为宿主不是组件自身模板的一部分,而是父组件模板的一部分。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "Use the *function form* to apply host styles conditionally by\nincluding another selector inside parentheses after `:host`.",
- "translation": "要把宿主样式作为条件,就要像*函数*一样把其它选择器放在`:host`后面的括号中。",
+ "translation": "要把宿主样式作为条件,就要像*函数*一样把其它选择器放在 `:host` 后面的括号中。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "The next example targets the host element again, but only when it also has the `active` CSS class.",
- "translation": "在下一个例子中,我们又一次把宿主元素作为目标,但是只有当它同时带有`active` CSS 类的时候才会生效。",
+ "translation": "下一个例子再次把宿主元素作为目标,但是只有当它同时带有 `active` CSS 类的时候才会生效。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
@@ -4701,22 +5876,22 @@
},
{
"original": "Sometimes it's useful to apply styles based on some condition *outside* of a component's view.\nFor example, a CSS theme class could be applied to the document `` element, and\nyou want to change how your component looks based on that.",
- "translation": "有时候,基于某些来自组件视图*外部*的条件应用样式是很有用的。\n例如,在文档的``元素上可能有一个用于表示样式主题 (theme) 的 CSS 类,而我们应当基于它来决定组件的样式。",
+ "translation": "有时候,基于某些来自组件视图*外部*的条件应用样式是很有用的。\n例如,在文档的 `` 元素上可能有一个用于表示样式主题 (theme) 的 CSS 类,你应当基于它来决定组件的样式。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "Use the `:host-context()` pseudo-class selector, which works just like the function\nform of `:host()`. The `:host-context()` selector looks for a CSS class in any ancestor of the component host element,\nup to the document root. The `:host-context()` selector is useful when combined with another selector.",
- "translation": "这时可以使用`:host-context()`伪类选择器。它也以类似`:host()`形式使用。它在当前组件宿主元素的*祖先节点*中查找 CSS 类,\n直到文档的根节点为止。在与其它选择器组合使用时,它非常有用。",
+ "translation": "这时可以使用 `:host-context()` 伪类选择器。它也以类似 `:host()` 形式使用。它在当前组件宿主元素的*祖先节点*中查找 CSS 类,\n直到文档的根节点为止。在与其它选择器组合使用时,它非常有用。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "The following example applies a `background-color` style to all `
` elements *inside* the component, only\nif some ancestor element has the CSS class `theme-light`.",
- "translation": "在下面的例子中,只有当某个祖先元素有 CSS 类`theme-light`时,我们才会把`background-color`样式应用到组件*内部*的所有`
` 元素中。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "### (deprecated) `/deep/`, `>>>`, and `::ng-deep`",
- "translation": "### 已废弃 `/deep/`、`>>>`和`::ng-deep`",
+ "translation": "### 已废弃 `/deep/`、`>>>` 和 `::ng-deep`",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
@@ -4726,27 +5901,27 @@
},
{
"original": "Use the `/deep/` shadow-piercing descendant combinator to force a style down through the child\ncomponent tree into all the child component views.\nThe `/deep/` combinator works to any depth of nested components, and it applies to both the view\nchildren and content children of the component.",
- "translation": "我们可以使用`/deep/`选择器,来强制一个样式对各级子组件的视图也生效,它*不但作用于组件的子视图,也会作用于组件的内容*。",
+ "translation": "可以使用 `/deep/` 选择器来强制一个样式对各级子组件的视图也生效,它*不但作用于组件的子视图,也会作用于组件的内容*。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "The following example targets all `
` elements, from the host element down\nthrough this component to all of its child elements in the DOM.",
- "translation": "在这个例子中,我们以所有的`
`元素为目标,从宿主元素到当前元素再到 DOM 中的所有子元素:",
+ "translation": "这个例子以所有的 `
` 元素为目标,从宿主元素到当前元素再到 DOM 中的所有子元素:",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "The `/deep/` combinator also has the aliases `>>>`, and `::ng-deep`.",
- "translation": "`/deep/` 组合器还有两个别名:`>>>`和`::ng-deep`。",
+ "translation": "`/deep/` 组合器还有两个别名:`>>>` 和 `::ng-deep`。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "Use `/deep/`, `>>>` and `::ng-deep` only with *emulated* view encapsulation.\nEmulated is the default and most commonly used view encapsulation. For more information, see the\n[Controlling view encapsulation](guide/component-styles#view-encapsulation) section.",
- "translation": "`/deep/`和`>>>`选择器只能被用在**仿真 (emulated) **模式下。\n这种方式是默认值,也是用得最多的方式。\n更多信息,见[控制视图封装模式](guide/component-styles#view-encapsulation)一节。",
+ "translation": "`/deep/` 和 `>>>` 选择器只能被用在**仿真 (emulated) **模式下。\n这种方式是默认值,也是用得最多的方式。\n更多信息,见[控制视图封装模式](guide/component-styles#view-encapsulation)一节。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
"original": "The shadow-piercing descendant combinator is deprecated and [support is being removed from major browsers](https://www.chromestatus.com/features/6750456638341120) and tools.\nAs such we plan to drop support in Angular (for all 3 of `/deep/`, `>>>` and `::ng-deep`).\nUntil then `::ng-deep` should be preferred for a broader compatibility with the tools.",
- "translation": "CSS标准中用于 \"刺穿Shadow DOM\" 的组合器已经被废弃,并将[这个特性从主流浏览器和工具中移除](https://www.chromestatus.com/features/6750456638341120)。\n因此,我们也将在 Angular 中移除对它们的支持(包括`/deep/`、`>>>` 和 `::ng-deep`)。\n目前,建议先统一使用`::ng-deep`,以便兼容将来的工具。",
+ "translation": "CSS 标准中用于 \"刺穿 Shadow DOM\" 的组合器已经被废弃,并将[这个特性从主流浏览器和工具中移除](https://www.chromestatus.com/features/6750456638341120)。\n因此,我们也将在 Angular 中移除对它们的支持(包括 `/deep/`、`>>>` 和 `::ng-deep`)。\n目前,建议先统一使用 `::ng-deep`,以便兼容将来的工具。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
@@ -4761,7 +5936,7 @@
},
{
"original": "* By setting `styles` or `styleUrls` metadata.",
- "translation": "设置`styles`或`styleUrls`元数据",
+ "translation": "设置 `styles` 或 `styleUrls` 元数据",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
@@ -4786,7 +5961,7 @@
},
{
"original": "You can add a `styles` array property to the `@Component` decorator.",
- "translation": "我们可以给`@Component`装饰器添加一个`styles`数组型属性。",
+ "translation": "你可以给 `@Component` 装饰器添加一个 `styles` 数组型属性。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
@@ -4811,7 +5986,7 @@
},
{
"original": "You can load styles from external CSS files by adding a `styleUrls` property\nto a component's `@Component` decorator:",
- "translation": "我们可以通过把外部 CSS 文件添加到 `@Component` 的 `styleUrls` 属性中来加载外部样式。",
+ "translation": "你可以通过把外部 CSS 文件添加到 `@Component` 的 `styleUrls` 属性中来加载外部样式。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
@@ -4821,7 +5996,7 @@
},
{
"original": "You can specify more than one styles file or even a combination of `style` and `styleUrls`.",
- "translation": "我们可以指定多个样式文件,甚至可以组合使用 `style` 和 `styleUrls` 方式。",
+ "translation": "你可以指定多个样式文件,甚至可以组合使用 `style` 和 `styleUrls` 方式。",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/component-styles.md"
},
{
@@ -4836,17 +6011,17 @@
},
{
"original": "You can embed CSS styles directly into the HTML template by putting them\ninside `