diff --git a/aio/content/guide/aot-compiler.md b/aio/content/guide/aot-compiler.md index 5db3fc288e..2f72c86c9a 100644 --- a/aio/content/guide/aot-compiler.md +++ b/aio/content/guide/aot-compiler.md @@ -13,7 +13,7 @@ This guide explains how to build with the AOT compiler using different compiler Watch compiler author Tobias Bosch explain the Angular Compiler at AngularConnect 2016. 观看 Angular 编译器的作者Tobias Bosch 在 AngularConnect 2016 上对编译器的解释。 - + {@a overview} @@ -35,10 +35,8 @@ Angular offers two ways to compile your application: JIT compilation is the default when you run the _build-only_ or the _build-and-serve-locally_ CLI commands: - ng build ng serve - {@a compile} @@ -46,10 +44,8 @@ JIT compilation is the default when you run the _build-only_ or the _build-and-s For AOT compilation, append the `--aot` flags to the _build-only_ or the _build-and-serve-locally_ CLI commands: - ng build --aot ng serve --aot -
@@ -126,6 +122,7 @@ You can control your app compilation by providing template compiler options in t `"angularCompilerOptions"` object as shown below: ```json + { "compilerOptions": { "experimentalDecorators": true, @@ -137,6 +134,7 @@ You can control your app compilation by providing template compiler options in t ... } } + ``` ### *skipMetadataEmit* @@ -316,6 +314,7 @@ In the following example, the `@Component()` metadata object and the class const 在下列范例中,`@Component()` 元数据对象和类的构造函数会告诉 Angular 如何创建和显示 `TypicalComponent` 的实例。 ```typescript + @Component({ selector: 'app-typical', template: '
A typical component for {{data.name}}
' @@ -324,6 +323,7 @@ export class TypicalComponent { @Input() data: TypicalData; constructor(private someService: SomeService) { ... } } + ``` The Angular compiler extracts the metadata _once_ and generates a _factory_ for `TypicalComponent`. @@ -435,10 +435,12 @@ piece of metadata to generate the application code. 如果你希望`ngc`立即汇报这些语法错误,而不要生成带有错误信息的`.metadata.json`文件,可以到`tsconfig`中设置 `strictMetadataEmit` 选项。 ``` + "angularCompilerOptions": { ... "strictMetadataEmit" : true } + ``` Angular libraries have this option to ensure that all Angular `.metadata.json` files are clean and it is a best practice to do the same when building your own libraries. @@ -448,6 +450,7 @@ Angular 库通过这个选项来确保所有的 `.metadata.json` 文件都是干
{@a function-expression} + {@a arrow-functions} ### No arrow functions @@ -458,10 +461,12 @@ and [arrow functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re Consider the following component decorator: ```typescript + @Component({ ... providers: [{provide: server, useFactory: () => new Server()}] }) + ``` The AOT _collector_ does not support the arrow function, `() => new Server()`, in a metadata expression. @@ -472,6 +477,7 @@ When the compiler later interprets this node, it reports an error that invites y You can fix the error by converting to this: ```typescript + export function serverFactory() { return new Server(); } @@ -480,6 +486,7 @@ export function serverFactory() { ... providers: [{provide: server, useFactory: serverFactory}] }) + ``` Beginning in version 5, the compiler automatically performs this rewritting while emitting the `.js` file. @@ -496,6 +503,7 @@ The compiler only supports calls to a small set of functions and will use `new` ### Folding {@a exported-symbols} + The compiler can only resolve references to **_exported_** symbols. Fortunately, the _collector_ enables limited use of non-exported symbols through _folding_. @@ -506,12 +514,14 @@ For example, the _collector_ can evaluate the expression `1 + 2 + 3 + 4` and rep This process is called _folding_. An expression that can be reduced in this manner is _foldable_. {@a var-declaration} + The collector can evaluate references to module-local `const` declarations and initialized `var` and `let` declarations, effectively removing them from the `.metadata.json` file. Consider the following component definition: ```typescript + const template = '
{{hero.name}}
'; @Component({ @@ -521,6 +531,7 @@ const template = '
{{hero.name}}
'; export class HeroComponent { @Input() hero: Hero; } + ``` The compiler could not refer to the `template` constant because it isn't exported. @@ -529,6 +540,7 @@ But the _collector_ can _fold_ the `template` constant into the metadata definit The effect is the same as if you had written: ```typescript + @Component({ selector: 'app-hero', template: '
{{hero.name}}
' @@ -536,6 +548,7 @@ The effect is the same as if you had written: export class HeroComponent { @Input() hero: Hero; } + ``` 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`. @@ -543,6 +556,7 @@ There is no longer a reference to `template` and, therefore, nothing to trouble You can take this example a step further by including the `template` constant in another expression: ```typescript + const template = '
{{hero.name}}
'; @Component({ @@ -552,6 +566,7 @@ const template = '
{{hero.name}}
'; export class HeroComponent { @Input() hero: Hero; } + ``` The _collector_ reduces this expression to its equivalent _folded_ string: @@ -600,6 +615,7 @@ Decorated component class members must be public. You cannot make an `@Input()` Data bound properties must also be public. ```typescript + // BAD CODE - title is private @Component({ selector: 'app-root', @@ -608,9 +624,11 @@ Data bound properties must also be public. export class AppComponent { private title = 'My App'; // Bad } + ``` {@a supported-functions} + Most importantly, the compiler only generates code to create instances of certain classes, support certain decorators, and call certain functions from the following lists. ### New instances @@ -650,9 +668,11 @@ methods that return an expression. For example, consider the following function: ```typescript + export function wrapInArray(value: T): T[] { return [value]; } + ``` 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. @@ -660,19 +680,23 @@ You can call the `wrapInArray` in a metadata definition because it returns the v You might use `wrapInArray()` like this: ```typescript + @NgModule({ declarations: wrapInArray(TypicalComponent) }) export class TypicalModule {} + ``` The compiler treats this usage as if you had written: ```typescript + @NgModule({ declarations: [TypicalComponent] }) export class TypicalModule {} + ``` The collector is simplistic in its determination of what qualifies as a macro @@ -692,6 +716,7 @@ the compiler doesn't need to know the expression's value—it just needs to You might write something like: ```typescript + class TypicalServer { } @@ -700,6 +725,7 @@ class TypicalServer { providers: [{provide: SERVER, useFactory: () => TypicalServer}] }) export class TypicalModule {} + ``` Without rewriting, this would be invalid because lambdas are not supported and `TypicalServer` is not exported. @@ -707,6 +733,7 @@ Without rewriting, this would be invalid because lambdas are not supported and ` To allow this, the compiler automatically rewrites this to something like: ```typescript + class TypicalServer { } @@ -717,6 +744,7 @@ export const ɵ0 = () => new TypicalServer(); providers: [{provide: SERVER, useFactory: ɵ0}] }) export class TypicalModule {} + ``` This allows the compiler to generate a reference to `ɵ0` in the @@ -751,6 +779,7 @@ Language features outside of the compiler's [restricted expression syntax](#expr can produce this error, as seen in the following example: ``` + // ERROR export class Fooish { ... } ... @@ -759,6 +788,7 @@ const prop = typeof Fooish; // typeof is not valid in metadata // bracket notation is not valid in metadata { provide: 'token', useValue: { [prop]: 'value' } }; ... + ``` You can use `typeof` and bracket notation in normal application code. @@ -785,6 +815,7 @@ The compiler encountered a referenced to a locally defined symbol that either wa Here's a `provider` example of the problem. ``` + // ERROR let foo: number; // neither exported nor initialized @@ -796,26 +827,33 @@ let foo: number; // neither exported nor initialized ] }) export class MyComponent {} + ``` + 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. You could fix the problem by initializing `foo`. ``` + let foo = 42; // initialized + ``` The compiler will [fold](#folding) the expression into the provider as if you had written this. ``` + providers: [ { provide: Foo, useValue: 42 } ] + ``` Alternatively, you can fix it by exporting `foo` with the expectation that `foo` will be assigned at runtime when you actually know its value. ``` + // CORRECTED export let foo: number; // exported @@ -827,6 +865,7 @@ export let foo: number; // exported ] }) export class MyComponent {} + ``` 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. @@ -836,6 +875,7 @@ in order to generate code. For example, it doesn't work for the `template` property. ``` + // ERROR export let someTemplate: string; // exported but not initialized @@ -844,6 +884,7 @@ export let someTemplate: string; // exported but not initialized template: someTemplate }) export class MyComponent {} + ``` The compiler needs the value of the `template` property _right now_ to generate the component factory. @@ -869,6 +910,7 @@ The following example tries to set the component's `template` property to the va the exported `someTemplate` variable which is declared but _unassigned_. ``` + // ERROR export let someTemplate: string; @@ -877,11 +919,13 @@ export let someTemplate: string; template: someTemplate }) export class MyComponent {} + ``` You'd also get this error if you imported `someTemplate` from some other module and neglected to initialize it there. ``` + // ERROR - not initialized there either import { someTemplate } from './config'; @@ -890,6 +934,7 @@ import { someTemplate } from './config'; template: someTemplate }) export class MyComponent {} + ``` The compiler cannot wait until runtime to get the template information. @@ -900,6 +945,7 @@ instructions for building the element based on the template. To correct this error, provide the initial value of the variable in an initializer clause _on the same line_. ``` + // CORRECTED export let someTemplate = '

Greetings from Angular

'; @@ -908,6 +954,7 @@ export let someTemplate = '

Greetings from Angular

'; template: someTemplate }) export class MyComponent {} + ```
@@ -926,6 +973,7 @@ For example, you may have defined a class and used it as an injection token in a but neglected to export that class. ``` + // ERROR abstract class MyStrategy { } @@ -934,6 +982,7 @@ abstract class MyStrategy { } { provide: MyStrategy, useValue: ... } ] ... + ``` Angular generates a class factory in a separate module and that @@ -941,6 +990,7 @@ factory [can only access exported classes](#exported-symbols). To correct this error, export the referenced class. ``` + // CORRECTED export abstract class MyStrategy { } @@ -949,6 +999,7 @@ export abstract class MyStrategy { } { provide: MyStrategy, useValue: ... } ] ... + ```
@@ -960,6 +1011,7 @@ Metadata referenced a function that wasn't exported. For example, you may have set a providers `useFactory` property to a locally defined function that you neglected to export. ``` + // ERROR function myStrategy() { ... } @@ -968,6 +1020,7 @@ function myStrategy() { ... } { provide: MyStrategy, useFactory: myStrategy } ] ... + ``` Angular generates a class factory in a separate module and that @@ -975,6 +1028,7 @@ factory [can only access exported functions](#exported-symbols). To correct this error, export the function. ``` + // CORRECTED export function myStrategy() { ... } @@ -983,6 +1037,7 @@ export function myStrategy() { ... } { provide: MyStrategy, useFactory: myStrategy } ] ... + ```
@@ -1001,6 +1056,7 @@ The compiler does not currently support [function expressions or lambda function For example, you cannot set a provider's `useFactory` to an anonymous function or arrow function like this. ``` + // ERROR ... providers: [ @@ -1008,9 +1064,13 @@ For example, you cannot set a provider's `useFactory` to an anonymous function o { provide: OtherStrategy, useFactory: () => { ... } } ] ... + ``` + You also get this error if you call a function or method in a provider's `useValue`. + ``` + // ERROR import { calculateValue } from './utilities'; @@ -1019,12 +1079,12 @@ import { calculateValue } from './utilities'; { provide: SomeValue, useValue: calculateValue() } ] ... + ``` To correct this error, export a function from the module and refer to the function in a `useFactory` provider instead. - // CORRECTED import { calculateValue } from './utilities'; @@ -1040,7 +1100,6 @@ export function someValueFactory() { { provide: SomeValue, useFactory: someValueFactory } ] ... -
@@ -1060,7 +1119,6 @@ The compiler does not support references to variables assigned by [destructuring For example, you cannot write something like this: - // ERROR import { configuration } from './configuration'; @@ -1072,13 +1130,11 @@ const {foo, bar} = configuration; {provide: Bar, useValue: bar}, ] ... - To correct this error, refer to non-destructured values. - // CORRECTED import { configuration } from './configuration'; ... @@ -1087,7 +1143,6 @@ import { configuration } from './configuration'; {provide: Bar, useValue: configuration.bar}, ] ... -
@@ -1103,12 +1158,15 @@ You'll get an error if you reference it in the component constructor, which the compiler must statically analyze. ``` + // ERROR @Component({ }) export class MyComponent { constructor (private win: Window) { ... } } + ``` + TypeScript understands ambiant types so you don't import them. The Angular compiler does not understand a type that you neglect to export or import. @@ -1130,7 +1188,6 @@ you can finesse the problem in four steps: Here's an illustrative example. - // CORRECTED import { Inject } from '@angular/core'; @@ -1146,7 +1203,6 @@ export function _window() { return window; } export class MyComponent { constructor (@Inject(WINDOW) private win: Window) { ... } } - The `Window` type in the constructor is no longer a problem for the compiler because it @@ -1155,7 +1211,6 @@ uses the `@Inject(WINDOW)` to generate the injection code. 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). - import { Inject } from '@angular/core'; import { DOCUMENT } from '@angular/platform-browser'; @@ -1163,7 +1218,6 @@ import { DOCUMENT } from '@angular/platform-browser'; export class MyComponent { constructor (@Inject(DOCUMENT) private doc: Document) { ... } } -
@@ -1174,15 +1228,19 @@ The compiler expected a name in an expression it was evaluating. This can happen if you use a number as a property name as in the following example. ``` + // ERROR provider: [{ provide: Foo, useValue: { 0: 'test' } }] + ``` Change the name of the property to something non-numeric. ``` + // CORRECTED provider: [{ provide: Foo, useValue: { '0': 'test' } }] + ```
@@ -1195,7 +1253,6 @@ that you referenced in metadata. The compiler can understand simple enum values but not complex values such as those derived from computed properties. - // ERROR enum Colors { Red = 1, @@ -1210,7 +1267,6 @@ enum Colors { { provide: StrongColor, useValue: Colors.Blue } // bad ] ... - Avoid referring to enums with complicated initializers or computed properties. @@ -1228,14 +1284,18 @@ _Tagged template expressions are not supported in metadata._ 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, + ``` + // ERROR const expression = 'funky'; const raw = String.raw`A tagged template ${expression} string`; ... template: '
' + raw + '
' ... + ``` + [`String.raw()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw) is a _tag function_ native to JavaScript ES2015. @@ -1254,6 +1314,7 @@ This error can occur if you use an expression in the `extends` clause of a class Chuck: After reviewing your PR comment I'm still at a loss. See [comment there](https://github.com/angular/angular/pull/17712#discussion_r132025495). --> + {@a binding-expresion-validation} ## Phase 3: binding expression validation @@ -1270,6 +1331,7 @@ Chuck: After reviewing your PR comment I'm still at a loss. See [comment there]( For example, consider the following component: ```typescript + @Component({ selector: 'my-component', template: '{{person.addresss.street}}' @@ -1277,12 +1339,15 @@ Chuck: After reviewing your PR comment I'm still at a loss. See [comment there]( class MyComponent { person?: Person; } + ``` This will produce the following error: ``` + my.component.ts.MyComponent.html(1,1): : Property 'addresss' does not exist on type 'Person'. Did you mean 'address'? + ``` The file name reported in the error message, `my.component.ts.MyComponent.html`, is a synthetic file @@ -1307,6 +1372,7 @@ Chuck: After reviewing your PR comment I'm still at a loss. See [comment there]( interpolation if the value of `person` is initialized as shown below: ```typescript + @Component({ selector: 'my-component', template: ' {{person.addresss.street}} ' @@ -1314,6 +1380,7 @@ Chuck: After reviewing your PR comment I'm still at a loss. See [comment there]( class MyComponent { person?: Person; } + ``` Using `*ngIf` allows the TypeScript compiler to infer that the `person` used in the @@ -1326,7 +1393,9 @@ Chuck: After reviewing your PR comment I'm still at a loss. See [comment there]( like `*ngIf`. This static member for `*ngIf` is: ```typescript + public static ngIfUseIfTypeGuard: void; + ``` This declares that the input property `ngIf` of the `NgIf` directive should be treated as a @@ -1346,6 +1415,7 @@ Chuck: After reviewing your PR comment I'm still at a loss. See [comment there]( is suppressed in the example by using `address!.street`. ```typescript + @Component({ selector: 'my-component', template: ' {{person.name}} lives on {{address!.street}} ' @@ -1359,6 +1429,7 @@ Chuck: After reviewing your PR comment I'm still at a loss. See [comment there]( this.address = address; } } + ``` The non-null assertion operator should be used sparingly as refactoring of the component @@ -1368,6 +1439,7 @@ Chuck: After reviewing your PR comment I'm still at a loss. See [comment there]( in the `*ngIf`as shown below: ```typescript + @Component({ selector: 'my-component', template: ' {{person.name}} lives on {{address.street}} ' @@ -1381,6 +1453,7 @@ Chuck: After reviewing your PR comment I'm still at a loss. See [comment there]( this.address = address; } } + ``` ### Disabling type checking using `$any()` @@ -1394,6 +1467,7 @@ Chuck: After reviewing your PR comment I'm still at a loss. See [comment there]( by casting `person` to the `any` type. ```typescript + @Component({ selector: 'my-component', template: '{{$any(person).addresss.street}}' @@ -1401,6 +1475,7 @@ Chuck: After reviewing your PR comment I'm still at a loss. See [comment there]( class MyComponent { person?: Person; } + ``` ## Summary diff --git a/aio/tools/translator/dict-1.json b/aio/tools/translator/dict-1.json index d48341365e..1f9824cc43 100644 --- a/aio/tools/translator/dict-1.json +++ b/aio/tools/translator/dict-1.json @@ -121,7 +121,7 @@ }, { "original": "For more information, see [Filters/pipes](guide/ajs-quick-reference#filters-pipes) below.", - "translation": "请参见下面[过滤器/管道](guide/ajs-quick-reference#filters-pipes)了解更多信息。", + "translation": "请参见下面[过滤器/管道](guide/ajs-quick-reference#filters-pipes)了解更多信息。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -146,7 +146,7 @@ }, { "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)部分。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -181,7 +181,7 @@ }, { "original": "For more information see the [Setup](guide/setup) page.", - "translation": "要了解更多,参见[搭建本地开发环境](guide/setup)。", + "translation": "要了解更多,参见[搭建本地开发环境](guide/setup)。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -314,14 +314,9 @@ "translation": "`ng-href`指令允许AngularJS对`href`属性进行预处理,以便它能在浏览器获取那个URL之前,使用一个返回适当URL的绑定表达式替换它。", "sourceFile": "/Users/twer/private/GDE/content-1/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`通常用来作为导航的一部分,激活一个路由。", - "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" - }, { "original": "Routing is handled differently in Angular.", - "translation": "路由在Angular中的处理方式不同。", + "translation": "路由在Angular中的处理方式不同。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -356,7 +351,7 @@ }, { "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中移除。", + "translation": "在这个例子中,除非`movies`数组的长度大于0,否则`
`元素就会被从DOM中移除。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -396,7 +391,7 @@ }, { "original": "In this example, the table row (``) element repeats for each movie object in the collection of movies.", - "translation": "在这个例子中,对`movies`集合中的每一个`movie`对象重复渲染了这个表格行元素(``)。", + "translation": "在这个例子中,对`movies`集合中的每一个`movie`对象重复渲染了这个表格行元素(``)。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -411,7 +406,7 @@ }, { "original": "For more information, see [Structural Directives](guide/structural-directives).", - "translation": "要了解更多信息,参见[结构性指令](guide/structural-directives)。", + "translation": "要了解更多信息,参见[结构性指令](guide/structural-directives)。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -421,7 +416,7 @@ }, { "original": "In this example, the `
` element is shown if the `favoriteHero` variable is truthy.", - "translation": "在这个例子中,如果`favoriteHero`变量为真,`
`元素就会显示出来。", + "translation": "在这个例子中,如果`favoriteHero`变量为真,`
`元素就会显示出来。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -551,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中很相似,只是有些参数变化了。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -581,17 +576,17 @@ }, { "original": "The Angular `json` pipe does the same thing.", - "translation": "Angular的`json`管道做完全相同的事。", + "translation": "Angular的`json`管道做完全相同的事。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { "original": "Selects up to the first parameter (2) number of items from the collection\n starting (optionally) at the beginning index (0).", - "translation": "从集合中选择从(第二参数指定的)起始索引号(0)开始的最多(第一参数指定的)条目数(2)个条目。", + "translation": "从集合中选择从(第二参数指定的)起始索引号(0)开始的最多(第一参数指定的)条目数(2)个条目。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { "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中一样,如果们改用组件中的代码实现此操作,性能将会提升。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -601,7 +596,7 @@ }, { "original": "The Angular `lowercase` pipe does the same thing.", - "translation": "Angular的`lowercase`管道和1中的功能完全相同。", + "translation": "Angular的`lowercase`管道和1中的功能完全相同。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -616,12 +611,12 @@ }, { "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)百分比格式,如第三个范例所示。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/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排序了。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -676,7 +671,7 @@ }, { "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模块用来对控制器、服务和其它代码进行跟踪。第二个参数定义该模块依赖的其它模块列表。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -699,11 +694,6 @@ "translation": "要了解关于模块的更多知识,参见[NgModules](guide/ngmodule)。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, - { - "original": "### Controller registration", - "translation": "### 控制器注册", - "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" - }, { "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模块并把该控制器注册进去。", @@ -741,7 +731,7 @@ }, { "original": "In AngularJS, you write the code for the model and methods in a controller function.", - "translation": "在Angular1中,我们在控制器函数中写模型和方法的代码。", + "translation": "在Angular1中,我们在控制器函数中写模型和方法的代码。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -761,7 +751,7 @@ }, { "original": "For more information, see the [Components](guide/architecture#components) \n section of the [Architecture Overview](guide/architecture) page.", - "translation": "要了解关于组件的更多信息,参见[架构概览](guide/architecture)中的[组件](guide/architecture#components)部分。", + "translation": "要了解关于组件的更多信息,参见[架构概览](guide/architecture)中的[组件](guide/architecture#components)部分。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -791,7 +781,7 @@ }, { "original": "For more information, see the [Dependency injection](guide/architecture#dependency-injection) \n section of the [Architecture Overview](guide/architecture).", - "translation": "要了解关于依赖注入的更多信息,参见[架构概览](guide/architecture)中的[依赖注入](guide/architecture#dependency-injection)部分。", + "translation": "要了解关于依赖注入的更多信息,参见[架构概览](guide/architecture)中的[依赖注入](guide/architecture#dependency-injection)部分。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -806,7 +796,7 @@ }, { "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`标签来为应用程序定义样式。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { @@ -1284,6 +1274,11 @@ "translation": "Angular应用主要包含组件和它们的HTML模板。\n在浏览器可以渲染应用之前,组件和模板必须要被**Angular编译器**转换为可以执行的JavaScript。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, + { + "original": "Watch compiler author Tobias Bosch explain the Angular Compiler at AngularConnect 2016.", + "translation": "观看编译器作者Tobias Bosch在AngularConnect 2016大会里,对Angular编译器的演讲。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" + }, { "original": "You can compile the app in the browser, at runtime, as the application loads, using the **_just-in-time_ (JIT) compiler**.\nThis is the standard development approach shown throughout the documentation.\nIt's great but it has shortcomings.", "translation": "你可以在浏览器中使用*即时编译器*(Just-in-Time - JIT)在运行期间编译该应用,也就是在应用加载时。\n这是本文档中展示过的标准开发方式。\n它很不错,但是有自己的缺点。", @@ -1804,6 +1799,11 @@ "translation": "你将需要单独的TypeScript配置文件,像这些:", "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, + { + "original": "", + "translation": "
\n @Types和node模块\n
In the file structure of _this particular sample project_,\nthe `node_modules` folder happens to be two levels up from the project root.\nTherefore, `\"typeRoots\"` must be set to `\"../../node_modules/@types/\"`.", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" + }, { "original": "### Tree shaking", "translation": "### 摇树优化", @@ -2014,6 +2014,11 @@ "translation": "JavaScript 中,每个_文件_是一个模块,文件中定义的所有对象都从属于那个模块。\n通过`export`关键字,模块可以把它的某些对象声明为公共的。\n其它 JavaScript 模块可以使用*import 语句*来访问这些公共对象。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/architecture.md" }, + { + "original": "", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/architecture.md" + }, { "original": "These are two different and _complementary_ module systems. Use them both to write your apps.", "translation": "这两个模块化系统是互补的,我们在写程序时都会用到。", @@ -2059,6 +2064,11 @@ "translation": "这两个系统比较容易混淆,因为它们共享相同的词汇 “imports” 和 “exports”。不过没关系,先放一放,随着时间和经验的增长,自然就清楚了。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/architecture.md" }, + { + "original": "
", + "translation": "Learn more from the [NgModules](guide/ngmodule) page.\n更多信息,见 [Angular 模块](guide/ngmodule)。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/architecture.md" + }, { "original": "## Components", "translation": "## 组件", @@ -2145,8 +2155,8 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/architecture.md" }, { - "original": "Metadata tells Angular how to process a class.", - "translation": "

元数据告诉 Angular 如何处理一个类。

", + "original": "

", + "translation": "元数据告诉 Angular 如何处理一个类。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/architecture.md" }, { @@ -2226,7 +2236,7 @@ }, { "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 如何把二者联系起来。As the diagram shows, there are four forms of data binding syntax. Each form has a direction — to the DOM, from the DOM, or in both directions.如图所示,数据绑定的语法有四种形式。每种形式都有一个方向 —— 绑定到 DOM 、绑定自 DOM 以及双向绑定。", + "translation": "Angular 支持**数据绑定**,一种让模板的各部分与组件的各部分相互合作的机制。\n我们往模板 HTML 中添加绑定标记,来告诉 Angular 如何把二者联系起来。As the diagram shows, there are four forms of data binding syntax. Each form has a direction — to the DOM, from the DOM, or in both directions.如图所示,数据绑定的语法有四种形式。每种形式都有一个方向 —— 绑定到 DOM 、绑定自 DOM 以及双向绑定。
", "sourceFile": "/Users/twer/private/GDE/content-1/guide/architecture.md" }, { @@ -2266,7 +2276,7 @@ }, { "original": "Data binding plays an important role in communication between a template and its component.", - "translation": "数据绑定在模板与对应组件的交互中扮演了重要的角色。", + "translation": "数据绑定在模板与对应组件的交互中扮演了重要的角色。\n
", "sourceFile": "/Users/twer/private/GDE/content-1/guide/architecture.md" }, { @@ -2441,7 +2451,7 @@ }, { "original": "_Dependency injection_ is a way to supply a new instance of a class\nwith the fully-formed dependencies it requires. Most dependencies are services.\nAngular uses dependency injection to provide new components with the services they need.", - "translation": "“依赖注入”是提供类的新实例的一种方式,还负责处理好类所需的全部依赖。大多数依赖都是服务。\nAngular 使用依赖注入来提供新组件以及组件所需的服务。", + "translation": "“依赖注入”是提供类的新实例的一种方式,还负责处理好类所需的全部依赖。大多数依赖都是服务。\nAngular 使用依赖注入来提供新组件以及组件所需的服务。
", "sourceFile": "/Users/twer/private/GDE/content-1/guide/architecture.md" }, { @@ -2800,7 +2810,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/attribute-directives.md" }, { - "original": "file that looks like this:", + "original": "Put the template in its own app.component.html\nfile that looks like this:", "translation": "我们把这个模板放到它的app.component.html文件中,就像这样:", "sourceFile": "/Users/twer/private/GDE/content-1/guide/attribute-directives.md" }, @@ -2819,6 +2829,11 @@ "translation": "运行应用,就会看到我们的指令确实高亮了段落中的文本。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/attribute-directives.md" }, + { + "original": "

Your directive isn't working?

", + "translation": "### 你的指令没生效?", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/attribute-directives.md" + }, { "original": "Did you remember to add the directive to the `declarations` attribute of `@NgModule`?\nIt is easy to forget!", "translation": "你记着设置`@NgModule`的`declarations`数组了吗?它很容易被忘掉。", @@ -3455,28 +3470,28 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/browser-support.md" }, { - "original": "Feature", + "original": "
", "sourceFile": "/Users/twer/private/GDE/content-1/guide/browser-support.md" }, { @@ -3489,6 +3504,21 @@ "translation": "如果你使用下列已废弃的i18n管道:\n [date](api/common/DeprecatedDatePipe)、[currency](api/common/DeprecatedCurrencyPipe)、[decimal](api/common/DeprecatedDecimalPipe) 和 [percent](api/common/DeprecatedPercentPipe)", "sourceFile": "/Users/twer/private/GDE/content-1/guide/browser-support.md" }, + { + "original": "All but Chrome, Firefox, Edge, IE11 and Safari 10", + "translation": "除了 Chrome、Firefox、Edge、IE11 和 Safari 10 外的所有浏览器", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/browser-support.md" + }, + { + "original": "[NgClass](api/common/NgClass) on SVG elements", + "translation": "在 SVG 元素上应用 [NgClass](api/common/NgClass)", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/browser-support.md" + }, + { + "original": "[Http](guide/http) when sending and receiving binary data", + "translation": "用 [Http](guide/http) 发送和接收二进制数据", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/browser-support.md" + }, { "original": "### Suggested polyfills ##", "translation": "### 建议的填充库 ##\nBelow are the polyfills which are used to test the framework itself. They are a good starting point for an application.", @@ -3934,6 +3964,71 @@ "translation": "[生命周期钩子](guide/lifecycle-hooks)章现在更加简短,并且对强调了Angular是以什么顺序来调用钩子方法的。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/change-log.md" }, + { + "original": "

Cheat Sheet

", + "translation": "

速查表

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/cheatsheet.md" + }, + { + "original": "Bootstrapping", + "translation": "启动", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/cheatsheet.md" + }, + { + "original": "Template syntax", + "translation": "模板语法", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/cheatsheet.md" + }, + { + "original": "Built-in directives", + "translation": "内置指令", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/cheatsheet.md" + }, + { + "original": "Forms", + "translation": "表单", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/cheatsheet.md" + }, + { + "original": "Class decorators", + "translation": "类装饰器(decorator)", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/cheatsheet.md" + }, + { + "original": "Directive configuration", + "translation": "指令配置", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/cheatsheet.md" + }, + { + "original": "Does not support parent-child relationship selectors.", + "translation": "但不支持指定父子关系的选择器。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/cheatsheet.md" + }, + { + "original": "Component configuration", + "translation": "组件配置", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/cheatsheet.md" + }, + { + "original": "Class field decorators for directives and components", + "translation": "给指令或组件类用的属性装饰器", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/cheatsheet.md" + }, + { + "original": "Directive and component change detection and lifecycle hooks", + "translation": "指令和组件的变更检测与生命周期钩子", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/cheatsheet.md" + }, + { + "original": "Dependency injection configuration", + "translation": "依赖注入的配置", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/cheatsheet.md" + }, + { + "original": "Routing and navigation", + "translation": "路由与导航", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/cheatsheet.md" + }, { "original": "# Component Interaction", "translation": "# 组件之间的交互", @@ -4009,6 +4104,11 @@ "translation": "运行应用程序会显示三个英雄:", "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" }, + { + "original": "

Test it

", + "translation": "### 测试", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" + }, { "original": "E2E test that all children were instantiated and displayed as expected:", "translation": "端到端测试,用于确保所有的子组件都像所期待的那样被初始化并显示出来。", @@ -4039,6 +4139,11 @@ "translation": "下面的`NameParentComponent`展示了各种名字的处理方式,包括一个全是空格的名字。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" }, + { + "original": "

Test it

", + "translation": "### 测试", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" + }, { "original": "E2E tests of input property setter with empty and non-empty names:", "translation": "端到端测试:输入属性的setter,分别使用空名字和非空名字。", @@ -4084,6 +4189,11 @@ "translation": "下面是点击按钮的结果。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" }, + { + "original": "

Test it

", + "translation": "### 测试", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" + }, { "original": "Test that ***both*** input properties are set initially and that button clicks trigger \nthe expected `ngOnChanges` calls and values:", "translation": "测试确保***这两个***输入属性值都被初始化了,当点击按钮后,`ngOnChanges`应该被调用,属性的值也符合预期。", @@ -4124,6 +4234,11 @@ "translation": "框架(Angular)把事件参数(用`$event`表示)传给事件处理方法,这个方法会处理:", "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" }, + { + "original": "

Test it

", + "translation": "### 测试", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" + }, { "original": "Test that clicking the *Agree* and *Disagree* buttons update the appropriate counters:", "translation": "测试确保点击*Agree*和*Disagree*按钮时,计数器被正确更新。", @@ -4145,7 +4260,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" }, { - "original": "{@a countdown-timer-example} \nThe following is a child `CountdownTimerComponent` that repeatedly counts down to zero and launches a rocket. It has `start` and `stop` methods that control the clock and it displays a countdown status message in its own template.", + "original": "The following is a child `CountdownTimerComponent` that repeatedly counts down to zero and launches a rocket. It has `start` and `stop` methods that control the clock and it displays a countdown status message in its own template.", "translation": "子组件`CountdownTimerComponent`进行倒计时,归零时发射一个导弹。`start`和`stop`方法负责控制时钟并在模板里显示倒计时的状态信息。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" }, @@ -4174,6 +4289,11 @@ "translation": "下面是父组件和子组件一起工作时的效果。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" }, + { + "original": "

Test it

", + "translation": "### 测试", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" + }, { "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*按钮来停止倒计时:", @@ -4259,6 +4379,11 @@ "translation": "使用`setTimeout()`来等下一轮,然后改写`seconds()`方法,这样它接下来就会从注入的这个计时器组件里获取秒数的值。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" }, + { + "original": "

Test it

", + "translation": "

测试一下!

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" + }, { "original": "Use [the same countdown timer tests](guide/component-interaction#countdown-tests) as before.", "translation": "使用和之前[一样的倒计时测试](guide/component-interaction#countdown-tests)。", @@ -4314,6 +4439,11 @@ "translation": "*History*日志证明了:在父组件`MissionControlComponent`和子组件`AstronautComponent`之间,信息通过该服务实现了双向传递。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" }, + { + "original": "

Test it

", + "translation": "### 测试", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/component-interaction.md" + }, { "original": "Tests click buttons of both the parent `MissionControlComponent` and the `AstronautComponent` children\nand verify that the history meets expectations:", "translation": "测试确保点击父组件`MissionControlComponent`和子组件`AstronautComponent`两个的组件的按钮时,*History*日志和预期的一样。", @@ -4736,7 +4866,7 @@ }, { "original": "Dependency Injection is a powerful pattern for managing code dependencies. \nThis cookbook explores many of the features of Dependency Injection (DI) in Angular.", - "translation": "依赖注入是一个用来管理代码依赖的强大模式。在这本“烹饪宝典”中,我们会讨论Angular依赖注入的许多特性。\n{@a toc}", + "translation": "依赖注入是一个用来管理代码依赖的强大模式。在这本“烹饪宝典”中,我们会讨论Angular依赖注入的许多特性。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection-in-action.md" }, { @@ -4875,7 +5005,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection-in-action.md" }, { - "original": "of the code in this cookbook.", + "original": "See the \nof the code in this cookbook.", "translation": "要获取本“烹饪宝典”的代码,**参见**。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection-in-action.md" }, @@ -5105,7 +5235,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection-in-action.md" }, { - "original": "and confirm that the three `HeroBioComponent` instances have their own cached hero data.", + "original": "Find this example in live code\nand confirm that the three `HeroBioComponent` instances have their own cached hero data.", "translation": "到在线例子中找到这个例子,确认三个`HeroBioComponent`实例拥有自己独立的英雄数据缓存。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection-in-action.md" }, @@ -5205,8 +5335,8 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection-in-action.md" }, { - "original": "`EXCEPTION: No provider for LoggerService! (HeroContactComponent -> LoggerService)`", - "translation": "另一方面,如果恢复`@Host()`装饰器,注释掉`@Optional`,应用程序就会运行失败,因为它在宿主组件级别找不到需要的日志服务。", + "original": "On the other hand, if you restore the `@Host()` decorator and comment out `@Optional`,\nthe application fails for lack of the required logger at the host component level.\n
\n`EXCEPTION: No provider for LoggerService! (HeroContactComponent -> LoggerService)`", + "translation": "另一方面,如果恢复`@Host()`装饰器,注释掉`@Optional`,应用程序就会运行失败,因为它在宿主组件级别找不到需要的日志服务。\n
\n`EXCEPTION: No provider for LoggerService! (HeroContactComponent -> LoggerService)`", "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection-in-action.md" }, { @@ -5490,7 +5620,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection-in-action.md" }, { - "original": "for the full source code.", + "original": "The function retrieves candidate heroes from the `HeroService`,\ntakes `2` of them to be the runners-up, and returns their concatenated names.\nLook at the \nfor the full source code.", "translation": "该函数从`HeroService`获取英雄参赛者,从中取`2`个作为亚军,并把他们的名字拼接起来。请到查看全部原代码。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection-in-action.md" }, @@ -5506,7 +5636,7 @@ }, { "original": "But the token doesn't have to be a class and even when it is a class,\nit doesn't have to be the same type as the returned object.\nThat's the subject of the next section.", - "translation": "但令牌不一定都是类,就算它是一个类,它也不一定都返回类型相同的对象。这是下一节的主题。\n{@a class-interface}", + "translation": "但令牌不一定都是类,就算它是一个类,它也不一定都返回类型相同的对象。这是下一节的主题。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection-in-action.md" }, { @@ -5705,7 +5835,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection-in-action.md" }, { - "original": "confirms that the `alex` parameter is set.", + "original": "Notice that even though the [@Optional](guide/dependency-injection-in-action#optional) qualifier\nis there for safety,\nthe \nconfirms that the `alex` parameter is set.", "translation": "安全起见,我们添加了[@Optional](guide/dependency-injection-in-action#optional)装饰器,但是显示`alex`参数确实被设置了。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection-in-action.md" }, @@ -5750,7 +5880,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection-in-action.md" }, { - "original": "confirms that the `alex` parameter is null.\n*You cannot inject a parent by its base class.*", + "original": "Unfortunately, this does not work.\nThe \nconfirms that the `alex` parameter is null.\n*You cannot inject a parent by its base class.*", "translation": "可惜这样不行。显示`alex`参数是null。\n*不能通过基类注入父组件*。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection-in-action.md" }, @@ -6040,8 +6170,8 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection.md" }, { - "original": "{@a ctor-injection}\nThat's super easy. Change the `Car` constructor to a version with DI:", - "translation": "{@a ctor-injection}\n答案非常简单。把`Car`的构造函数改造成使用 DI 的版本:", + "original": "{@a ctor-injection}", + "translation": "答案非常简单。把`Car`的构造函数改造成使用 DI 的版本:", "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection.md" }, { @@ -6399,6 +6529,16 @@ "translation": "建议为每个服务类都添加`@Injectable()`,包括那些没有依赖严格来说并不需要它的。因为:", "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection.md" }, + { + "original": "Future proofing: No need to remember @Injectable() when you add a dependency later.", + "translation": "面向未来: 没有必要记得在后来添加依赖的时候添加 @Injectable()。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection.md" + }, + { + "original": "Consistency: All services follow the same rules, and you don't have to wonder why a decorator is missing.", + "translation": "一致性:所有的服务都遵循同样的规则,不需要考虑为什么某个地方少了一个。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection.md" + }, { "original": "Injectors are also responsible for instantiating components\nlike `HeroesComponent`. So why doesn't `HeroesComponent` have\n`@Injectable()`?", "translation": "注入器同时负责实例化像`HerosComponent`这样的组件。为什么不标记`HerosComponent`为`@Injectable()`呢?", @@ -6469,11 +6609,6 @@ "translation": "如果忘了注册这个日志服务,Angular 会在首次查找这个日志服务时,抛出一个异常。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection.md" }, - { - "original": "", - "translation": "EXCEPTION: No provider for Logger! (HeroListComponent -> HeroService -> Logger)\n (异常:Logger类没有提供商!(HeroListComponent -> HeroService -> Logger))", - "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection.md" - }, { "original": "That's Angular telling you that the dependency injector couldn't find the *provider* for the logger.\nIt needed that provider to create a `Logger` to inject into a new\n`HeroService`, which it needed to\ncreate and inject into a new `HeroListComponent`.", "translation": "Angular 告诉我们,依赖注入器找不到日志服务的*提供商*。\n在创建`HeroListComponent`的新实例时需要创建并注入`HeroService`,\n而`HeroService`需要创建并注入一个`Logger`实例,\nAngular 需要这个`Logger`实例的提供商来。", @@ -6729,16 +6864,6 @@ "translation": "### 非类依赖", "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection.md" }, - { - "original": "What if the dependency value isn't a class? Sometimes the thing you want to inject is a\n string, function, or object.", - "translation": "如果依赖值不是一个类呢?有时候想要注入的东西是一个字符串,函数或者对象。", - "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection.md" - }, - { - "original": "Applications often define configuration objects with lots of small facts\n (like the title of the application or the address of a web API endpoint)\n but these configuration objects aren't always instances of a class.\n They can be object literals such as this one:", - "translation": "应用程序经常为很多很小的因素定义配置对象(例如应用程序的标题或网络API终点的地址)。\n 但是这些配置对象不总是类的实例,它们可能是对象,如下面这个:", - "sourceFile": "/Users/twer/private/GDE/content-1/guide/dependency-injection.md" - }, { "original": "What if you'd like to make this configuration object available for injection?\nYou know you can register an object with a [value provider](guide/dependency-injection#value-provider).", "translation": "我们想让这个配置对象在注入时可用,而且知道可以使用[值提供商](guide/dependency-injection#value-provider)来注册一个对象。", @@ -7219,6 +7344,11 @@ "translation": "### Webpack(与AOT)", "sourceFile": "/Users/twer/private/GDE/content-1/guide/deployment.md" }, + { + "original": "Webpack 2 is another\ngreat option for inlining templates and style-sheets, for bundling, minifying, and uglifying the application.\nThe \"[Webpack: an introduction](guide/webpack \"Webpack: an introduction\")\" guide will get you started\nusing webpack with Angular.", + "translation": "Webpack 2是另一个选项,它可以内联模板、样式表、打包、最小化和混淆应用。\n\"[Webpack简介](guide/webpack \"Webpack: an introduction\")\"一章中将会教你如何配合Angular使用Webpack。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/deployment.md" + }, { "original": "Consider configuring _Webpack_ with the official\n\nAngular Ahead-of-Time Webpack Plugin.\nThis plugin transpiles the TypeScript application code,\nbundles lazy loaded `NgModules` separately,\nand performs AOT compilation — without any changes to the source code.", "translation": "考虑使用官方的\nAngular预编译插件来配置*Webpack*。\n这个插件会转译TypeScript代码、独立打包延迟加载的`NgModules`,而且不用对源码做任何修改就能执行AOT编译。", @@ -7334,11 +7464,6 @@ "translation": "Angular应用默认运行在开发模式下,正如在浏览器控制台中看到的如下信息:", "sourceFile": "/Users/twer/private/GDE/content-1/guide/deployment.md" }, - { - "original": "", - "translation": "Angular is running in the development mode. Call enableProdMode() to enable the production mode.\n (Angular正运行在开发模式下。调用enableProdMode()来启用生产模式)", - "sourceFile": "/Users/twer/private/GDE/content-1/guide/deployment.md" - }, { "original": "Switching to production mode can make it run faster by disabling development specific checks such as the dual change detection cycles.", "translation": "切换到生产模式可以通过禁用开发环境下特有的检查(比如双重变更检测周期)来让应用运行得更快。", @@ -7860,7 +7985,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/dynamic-component-loader.md" }, { - "original": "of the code in this cookbook.", + "original": "See the \nof the code in this cookbook.", "translation": "到查看本烹饪书的源码。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/dynamic-component-loader.md" }, @@ -8171,7 +8296,7 @@ }, { "original": "`formControlName` and `formGroup` are directives defined in\n`ReactiveFormsModule`. The templates can access these directives\ndirectly since you imported `ReactiveFormsModule` from `AppModule`.", - "translation": "`formControlName`和`formGroup`是在`ReactiveFormsModule`中定义的指令。我们之所以能在模板中使用它们,是因为我们往`AppModule`中导入了`ReactiveFormsModule`。\n{@a questionnaire-data}", + "translation": "`formControlName`和`formGroup`是在`ReactiveFormsModule`中定义的指令。我们之所以能在模板中使用它们,是因为我们往`AppModule`中导入了`ReactiveFormsModule`。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/dynamic-form.md" }, { @@ -11150,7 +11275,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/http.md" }, { - "original": "intercept(req: HttpRequest, next: HttpHandler): Observable> {\n \tconst started = Date.now();\n return next\n .handle(req)\n .do(event => {\n if (event instanceof HttpResponse) {\n const elapsed = Date.now() - started;\n console.log(`Request for ${req.urlWithParams} took ${elapsed} ms.`);\n }\n });\n }\n}\n```\nNotice the RxJS `do()` operator—it adds a side effect to an Observable without affecting the values on the stream. Here, it detects the `HttpResponse` event and logs the time the request took.", + "original": "Notice the RxJS `do()` operator—it adds a side effect to an Observable without affecting the values on the stream. Here, it detects the `HttpResponse` event and logs the time the request took.", "translation": "注意 RxJS 的 `do()`操作符 —— 它为可观察对象添加一个副作用,而不会影响到流中的值。这里,它会检测`HttpResponse`的事件,并且记录这个请求花费的时间。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/http.md" }, @@ -11235,7 +11360,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/http.md" }, { - "original": "*Note that `HttpClient`'s support is only the client half of the XSRF protection scheme.* Your backend service must be configured to set the cookie for your page, and to verify that the header is present on all eligible requests. If not, Angular's default protection will be ineffective.", + "original": "
\n*Note that `HttpClient`'s support is only the client half of the XSRF protection scheme.* Your backend service must be configured to set the cookie for your page, and to verify that the header is present on all eligible requests. If not, Angular's default protection will be ineffective.", "translation": "*注意,`HttpClient`支持的只是 XSRF 防护方案的客户端这一半。* 我们的后端服务必须配置为给页面设置 cookie ,并且要验证请求头,以确保全都是合法的请求。否则,Angular 默认的这种防护措施就会失效。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/http.md" }, @@ -11335,7 +11460,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/i18n.md" }, { - "original": "of a JIT-compiled app, translated into Spanish.", + "original": "Try this live example\nof a JIT-compiled app, translated into Spanish.", "translation": "**试试** 这个翻译为西班牙语版JiT编译应用的在线例子。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/i18n.md" }, @@ -11805,7 +11930,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/i18n.md" }, { - "original": "Note that the translation unit `id=introductionHeader` is derived from the [_custom_ `id`](#custom-id \"Set a custom id\") that you set earlier, but **without the `@@` prefix** required in the source HTML.", + "original": "
\nNote that the translation unit `id=introductionHeader` is derived from the [_custom_ `id`](#custom-id \"Set a custom id\") that you set earlier, but **without the `@@` prefix** required in the source HTML.", "translation": "注意,翻译单元`id=introductionHeader`派生自[*自定义*`id`](#custom-id \"设置自定义id\"),它设置起来更简单,但是在HTML源码中**不需要`@@`前缀**。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/i18n.md" }, @@ -12375,12 +12500,12 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/language-service.md" }, { - "original": "```sh\nnpm install --save-dev @angular/language-service\n```\nAdditionally, add the following to the `\"compilerOptions\"` section of \nyour project's `tsconfig.json`.", + "original": "Additionally, add the following to the `\"compilerOptions\"` section of \nyour project's `tsconfig.json`.", "translation": "另外,还要在工程的`tsconfig.json`中添加下列`\"compilerOptions\"`区域:", "sourceFile": "/Users/twer/private/GDE/content-1/guide/language-service.md" }, { - "original": "```json\n \"plugins\": [\n {\"name\": \"@angular/language-service\"}\n ]\n```\nNote that this only provides diagnostics and completions in `.ts` \nfiles. You need a custom sublime plugin (or modifications to the current plugin) \nfor completions in HTML files.", + "original": "Note that this only provides diagnostics and completions in `.ts` \nfiles. You need a custom sublime plugin (or modifications to the current plugin) \nfor completions in HTML files.", "translation": "注意,这只是提供了`.ts`文件中的诊断与自动完成。我们需要一个自定义的sublime插件(或修改现有插件)来在 HTML 文件中提供自动完成功能。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/language-service.md" }, @@ -12469,6 +12594,11 @@ "translation": "当Angular使用构造函数新建一个组件或指令后,就会按下面的顺序在特定时刻调用这些生命周期钩子方法:", "sourceFile": "/Users/twer/private/GDE/content-1/guide/lifecycle-hooks.md" }, + { + "original": "Hook", + "translation": "钩子", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/lifecycle-hooks.md" + }, { "original": "Respond when Angular (re)sets data-bound input properties.\n The method receives a `SimpleChanges` object of current and previous property values.", "translation": "当Angular(重新)设置数据绑定输入属性时响应。\n 该方法接受当前和上一属性值的`SimpleChanges`对象", @@ -12620,7 +12750,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/lifecycle-hooks.md" }, { - "original": "demonstrates the lifecycle hooks in action through a series of exercises\npresented as components under the control of the root `AppComponent`.", + "original": "The \ndemonstrates the lifecycle hooks in action through a series of exercises\npresented as components under the control of the root `AppComponent`.", "translation": "通过在受控于根组件`AppComponent`的一些组件上进行的一系列练习,演示了生命周期钩子的运作方式。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/lifecycle-hooks.md" }, @@ -12634,6 +12764,11 @@ "translation": "下面是每个练习简短的描述:", "sourceFile": "/Users/twer/private/GDE/content-1/guide/lifecycle-hooks.md" }, + { + "original": "Component", + "translation": "组件", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/lifecycle-hooks.md" + }, { "original": "Demonstrates every lifecycle hook.\n Each hook method writes to the on-screen log.", "translation": "展示每个生命周期钩子,每个钩子方法都会在屏幕上显示一条日志。", @@ -12749,6 +12884,11 @@ "translation": "不开玩笑了,注意下面两个关键点:", "sourceFile": "/Users/twer/private/GDE/content-1/guide/lifecycle-hooks.md" }, + { + "original": "1. Angular calls hook methods for *directives* as well as components.

", + "translation": "就像对组件一样,Angular也会对*指令*调用这些钩子方法。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/lifecycle-hooks.md" + }, { "original": "2. A spy directive can provide insight into a DOM object that you cannot change directly.\nObviously you can't touch the implementation of a native `
`.\nYou can't modify a third party component either.\nBut you can watch both with a directive.", "translation": "一个侦探(spy)指令可以让我们在无法直接修改DOM对象实现代码的情况下,透视其内部细节。\n显然,你不能修改一个原生`
`元素的实现代码。\n你同样不能修改第三方组件。\n但我们用一个指令就能监视它们了。", @@ -13624,6 +13764,11 @@ "translation": "更一般地说,[优先把提供商注册进模块中](guide/ngmodule-faq#q-component-or-module),而不是组件中。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" }, + { + "original": "

Discussion

", + "translation": "

讨论

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" + }, { "original": "Angular registers all startup module providers with the application root injector.\nThe services created from root injector providers are available to the entire application.\nThey are _application-scoped_.", "translation": "Angular把所有启动期模块的提供商都注册进了应用的根注入器中。\n这些服务是由根注入器中的提供商创建的,并且在整个应用中都可用。\n它们具有*应用级作用域*。", @@ -13720,7 +13865,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" }, { - "original": "To demonstrate, run the live example.\nModify the `SharedModule` so that it provides the `UserService` rather than the `CoreModule`.\nThen toggle between the \"Contact\" and \"Heroes\" links a few times.\nThe username goes bonkers as the Angular creates a new `UserService` instance each time.\n", + "original": "", "translation": "自己验证一下吧。\n运行这个在线例子。\n修改`SharedModule`,由它来提供`UserService`而不再由`CoreModule`。\n然后在“Contact”和“Heroes”链接之间切换几次。\n由于Angular每次都创建一个新的`UserService`实例,所以用户名变得不正常了。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" }, @@ -14236,7 +14381,7 @@ }, { "original": "Do *not* import service modules in other feature modules.\n If you deviate from this guideline, know what you're doing and why.", - "translation": "*不要*在任何特性模块中导入它们。\n 如果你要违背这条指导原则,请务必想清楚你在做什么,并要有充分的理由。", + "translation": "*不要*在任何特性模块中导入它们。\n 如果你要违背这条指导原则,请务必想清楚你在做什么,并要有充分的理由。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" }, { @@ -14329,6 +14474,16 @@ "translation": "顶级组件", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" }, + { + "original": "Feature, AppModule", + "translation": "特性模块和AppModule", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" + }, + { + "original": "ContactModule (before routing)", + "translation": "ContactModule(路由之前的那个例子)", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" + }, { "original": "Routed", "translation": "路由", @@ -14354,6 +14509,11 @@ "translation": "无", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" }, + { + "original": "ContactModule, HeroModule, CrisisModule", + "translation": "ContactModuleHeroModuleCrisisModule", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" + }, { "original": "Routing", "translation": "路由", @@ -14374,6 +14534,11 @@ "translation": "无", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" }, + { + "original": "HttpModule, CoreModule", + "translation": "HttpModuleCoreModule", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" + }, { "original": "Service", "translation": "服务", @@ -14394,6 +14559,11 @@ "translation": "无", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" }, + { + "original": "HttpModule, CoreModule", + "translation": "HttpModuleCoreModule", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" + }, { "original": "Widget", "translation": "窗口部件", @@ -14419,6 +14589,11 @@ "translation": "特性模块", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" }, + { + "original": "CommonModule, SharedModule", + "translation": "CommonModuleSharedModule", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" + }, { "original": "## What's the difference between Angular and JavaScript Modules?", "translation": "## Angular模块和JavaScript模块有什么区别?", @@ -14480,7 +14655,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" }, { - "original": "The NgModule is also special in another way.\nUnlike JavaScript modules, an NgModule can extend the _entire_ application with services\nby adding providers to the `@NgModule.providers` list.\n", + "original": "", "translation": "Angular模块还有些别的特殊之处。\n不同于JavaScript模块,Angular模块可以通过把服务提供商添加到`@NgModule.providers`数组中来扩展*整个*应用提供的服务。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" }, @@ -14751,7 +14926,7 @@ }, { "original": "Both are advanced techniques that few developers ever employ.\n If you are one of those few, you must add these components to the\n `entryComponents` list yourself, either programmatically or by hand.", - "translation": "所有这些高级技巧是只有极少数开发人员才会去用的。\n 如果你是其中的一位,那么你就不得不自行把这些组件添加到`entryComponents`列表中 —— 无论是用程序添加还是手动添加。", + "translation": "所有这些高级技巧是只有极少数开发人员才会去用的。\n 如果你是其中的一位,那么你就不得不自行把这些组件添加到`entryComponents`列表中 —— 无论是用程序添加还是手动添加。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule-faq.md" }, { @@ -14859,6 +15034,31 @@ "translation": "本章通过一个基于《英雄指南》的渐进式例子解释了 Angular 的模块。这里是例子演化过程中一些关键节点的在线例子。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, + { + "original": "* A minimal NgModule app", + "translation": "最小的 NgModule 应用", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, + { + "original": "* The first contact module", + "translation": "第一个联系人模块", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, + { + "original": "* The revised contact module", + "translation": "修改过的联系人模块", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, + { + "original": "* Just before adding SharedModule", + "translation": "添加 _SharedModule_ 之前", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, + { + "original": "* The final version", + "translation": "最终版", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, { "original": "#### Frequently asked questions (FAQs)", "translation": "### 常见问题", @@ -15019,6 +15219,11 @@ "translation": "这里的例子演示进行动态引导的方法。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, + { + "original": "Try the live example.", + "translation": "试试在线例子。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, { "original": "### Compile ahead-of-time (AOT)", "translation": "### 使用预编译器 (AoT - Ahead-Of-Time) 进行静态引导", @@ -15194,6 +15399,11 @@ "translation": "要解释这一点,我们可以再加入`ContactComponent`组件,它是一个表单组件,从 Angular 的`FormsModule`中导入了表单支持。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, + { + "original": "

Add the _ContactComponent_

", + "translation": "

添加 _ContactComponent_

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, { "original": "[Angular forms](guide/forms) are a great way to manage user data entry.", "translation": "[Angular 表单](guide/forms)是用来管理用户数据输入的最佳方式之一。", @@ -15205,7 +15415,12 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, { - "original": "You can write Angular form components in\ntemplate-driven or\n[reactive](guide/dynamic-form) style.\n", + "original": "

Angular form styles

", + "translation": "### Angular 表单的风格", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, + { + "original": "", "translation": "我们写 Angular 表单组件时,可以使用[_模板驱动式表单_](guide/forms),\n 也可以使用[_响应式表单_](guide/dynamic-form)。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, @@ -15254,6 +15469,11 @@ "translation": "退一步说,即使 Angular 有办法识别`ngModel`,`ContactComponent`也不会表现的像 Angular 表单,\n因为本组件表单的表单相关的特性(例如有效性验证)还不可用。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, + { + "original": "

Import the FormsModule

", + "translation": "

导入 FormsModule

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, { "original": "Add the `FormsModule` to the `AppModule` metadata's `imports` list.", "translation": "把`FormsModule`加到`AppModule`元数据中的`imports`列表中:", @@ -15279,6 +15499,11 @@ "translation": "**永远不要再次声明属于其它模块的类。**", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, + { + "original": "

Declare the contact component, directive, and pipe

", + "translation": "### 声明联系人的组件、指令和管道", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, { "original": "The application won't compile until you declare the contact component, directive, and pipe.\nUpdate the `declarations` in the `AppModule` accordingly:", "translation": "如果我们没有声明该联系人模块的组件、指令和管道,该应用就会失败。\n更新`AppModule`中的`declarations`元数据,就像这样:", @@ -15299,6 +15524,11 @@ "translation": "这解决了在文件中使用指令_类型_时的冲突问题,但是还有另一个问题没有解决,我们将在[后面](guide/ngmodule#resolve-conflicts)讨论它。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, + { + "original": "

Provide the _ContactService_

", + "translation": "

提供 _ContactService_

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, { "original": "The `ContactComponent` displays contacts retrieved by the `ContactService`,\nwhich Angular injects into its constructor.", "translation": "`ContactComponent`显示从`ContactService`服务中获取的联系人信息,该服务是被 Angular 注入到组件的构造函数中的。", @@ -15319,6 +15549,11 @@ "translation": "现在,`ContactService`服务就能被注入进该应用中的任何组件了,就像`UserService`一样。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, + { + "original": "

Application-scoped providers

", + "translation": "

全应用范围的提供商

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, { "original": "The `ContactService` provider is _application_-scoped because Angular\n registers a module's `providers` with the application's *root injector*.", "translation": "`ContactService`的提供商是_全应用_范围的,这是因为 Angular 使用该应用的**根注入器**注册模块的`providers`。", @@ -15349,6 +15584,11 @@ "translation": "在[NgModule常见问题](guide/ngmodule-faq)页的[如何把服务的范围限制在一个模块中](guide/ngmodule-faq#q-component-scoped-providers)一节中可以了解更多。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, + { + "original": "

Run the app

", + "translation": "

运行该应用

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, { "original": "Everything is in place to run the application with its contact editor.", "translation": "一切就绪,可以运行该应用及其联系人编辑器了。", @@ -15359,6 +15599,11 @@ "translation": "应用的文件结构是这样的:", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, + { + "original": "
", + "translation": "Try the example:\n试试这个例子:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, { "original": "## Resolve directive conflicts", "translation": "## 解决指令冲突", @@ -15664,6 +15909,11 @@ "translation": "试试范例的`ContactModule`版。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, + { + "original": "Try the live example.", + "translation": "试试在线例子", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, { "original": "## Lazy-loading modules with the router", "translation": "## 用路由器实现惰性 (lazy) 加载", @@ -15674,6 +15924,11 @@ "translation": "英雄职介所这个例子应用继续成长。\n它又增加了两个模块,一个用来管理雇佣的英雄,另一个用来匹配英雄与危机。\n这两个模块都还处于前期开发阶段。\n它们对于整个故事来说无关紧要,这里我们就不逐行讨论了。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, + { + "original": "Examine and download the complete source for this version from the\nlive example.", + "translation": "到在线例子\n试用并下载当前版本的完整代码。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, { "original": "Some facets of the current application merit discussion are as follows:", "translation": "当前应用中还有一些方面值得深入探讨。", @@ -15720,7 +15975,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, { - "original": "Some file names bear a `.3` extension that indicates\na difference with prior or future versions.\nThe significant differences will be explained in due course.\n", + "original": "", "translation": "有些文件名带有`.3`扩展名,用来和以前/以后的版本区分开。\n我们会在适当的时机解释它们的差异。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, @@ -16084,6 +16339,11 @@ "translation": "`CoreModule`_提供_了`UserService`。Angular 在该应用的根注入器中注册了它的提供商,\n导致这份`UserService`的实例在每个需要它的组件中都是可用的,无论那个组件时主动加载的还是惰性加载的。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" }, + { + "original": "

Why bother?

", + "translation": "

没必要?

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ngmodule.md" + }, { "original": "This scenario is clearly contrived.\nThe app is too small to worry about a single service file and a tiny, one-time component.", "translation": "这个场景设计的是有点生硬。\n该应用太小了,所以其实并不需要拆分出单独的服务文件和小型的、一次性的组件。", @@ -16339,6 +16599,11 @@ "translation": "Node.js和npm是做Angular开发的基础。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/npm-packages.md" }, + { + "original": "\nGet them now if they're not already installed on your machine.", + "translation": "如果你的电脑上还没有装过,请立即获取它!", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/npm-packages.md" + }, { "original": "**Verify that you are running node `v4.x.x` or higher and npm `3.x.x` or higher**\nby running the commands `node -v` and `npm -v` in a terminal/console window.\nOlder versions produce errors.", "translation": "通过在终端/控制台窗口中运行`node -v`和`npm -v`命令,来**验证下你是否正在使用node `v4.x.x`和npm `3.x.x`**。\n 过老的版本有可能出现问题。", @@ -16879,6 +17144,11 @@ "translation": "Angular通过*变更检测*过程来查找绑定值的更改,并在每一次JavaScript事件之后运行:每次按键、鼠标移动、定时器以及服务器的响应。\n这可能会让变更检测显得很昂贵,但是Angular会尽可能降低变更检测的成本。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" }, + { + "original": "

No pipe

", + "translation": "

无管道

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" + }, { "original": "In the next example, the component uses the default, aggressive change detection strategy to monitor and update\nits display of every hero in the `heroes` array. Here's the template:", "translation": "我们下一个例子中的组件使用默认的、激进(昂贵)的变更检测策略来检测和更新`heroes`数组中的每个英雄。下面是它的模板:", @@ -16894,6 +17164,11 @@ "translation": "我们可以添加新的英雄,加完之后,Angular就会更新显示。\n`reset`按钮会把`heroes`替换成一个由原来的英雄组成的新数组,重置完之后,Angular就会更新显示。\n如果我们提供了删除或修改英雄的能力,Angular也会检测到那些更改,并更新显示。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" }, + { + "original": "

FlyingHeroesPipe

", + "translation": "

“会飞的英雄”管道(FlyingHeroesPipe)

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" + }, { "original": "Add a `FlyingHeroesPipe` to the `*ngFor` repeater that filters the list of heroes to just those heroes who can fly.", "translation": "我们来往`*ngFor`重复器中添加一个`FlyingHeroesPipe`管道,这个管道能过滤出所有会飞的英雄。", @@ -16964,6 +17239,11 @@ "translation": "在继续往下走之前,我们先理解一下*纯*和*非纯*之间的区别,从*纯*管道开始。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" }, + { + "original": "

Pure pipes

", + "translation": "

纯管道

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" + }, { "original": "Angular executes a *pure pipe* only when it detects a *pure change* to the input value.\nA pure change is either a change to a primitive input value (`String`, `Number`, `Boolean`, `Symbol`)\nor a changed object reference (`Date`, `Array`, `Function`, `Object`).", "translation": "Angular只有在它检测到输入值发生了*纯变更*时才会执行*纯管道*。\n ***纯变更***是指对原始类型值(`String`、`Number`、`Boolean`、`Symbol`)的更改,\n 或者对对象引用(`Date`、`Array`、`Function`、`Object`)的更改。", @@ -16989,6 +17269,11 @@ "translation": "或者我们也可以完全不用管道。\n有时候,使用组件的属性能比用管道更好的达到目的,这一点我们等后面会再提起。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" }, + { + "original": "

Impure pipes

", + "translation": "### 非纯管道", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" + }, { "original": "Angular executes an *impure pipe* during every component change detection cycle.\nAn impure pipe is called often, as often as every keystroke or mouse-move.", "translation": "Angular会在每个组件的变更检测周期中执行*非纯管道*。\n非纯管道可能会被调用很多次,和每个按键或每次鼠标移动一样频繁。", @@ -16999,6 +17284,11 @@ "translation": "要在脑子里绷着这根弦,我们必须小心翼翼的实现非纯管道。\n一个昂贵、迟钝的管道将摧毁用户体验。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" }, + { + "original": "

An impure FlyingHeroesPipe

", + "translation": "### 非纯版本的*FlyingHeroesPipe*", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" + }, { "original": "A flip of the switch turns the `FlyingHeroesPipe` into a `FlyingHeroesImpurePipe`.\nThe complete implementation is as follows:", "translation": "我们把`FlyingHeroesPipe`换成了`FlyingHeroesImpurePipe`。\n下面是完整的实现:", @@ -17024,6 +17314,11 @@ "translation": "唯一的重大改动就是管道。\n 我们可以在中确认,当我们输入新的英雄甚至修改#[code heroes]数组时,这个#[i 会飞的英雄]的显示也跟着更新了。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" }, + { + "original": "

The impure AsyncPipe

", + "translation": "

\n 非纯 AsyncPipe\n

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" + }, { "original": "The Angular `AsyncPipe` is an interesting example of an impure pipe.\nThe `AsyncPipe` accepts a `Promise` or `Observable` as input\nand subscribes to the input automatically, eventually returning the emitted values.", "translation": "Angular的`AsyncPipe`是一个有趣的非纯管道的例子。\n `AsyncPipe`接受一个`Promise`或`Observable`作为输入,并且自动订阅这个输入,最终返回它们给出的值。", @@ -17044,6 +17339,11 @@ "translation": "这个Async管道节省了组件的样板代码。\n组件不用订阅这个异步数据源,而且不用在被销毁时取消订阅(如果订阅了而忘了反订阅容易导致隐晦的内存泄露)。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" }, + { + "original": "

An impure caching pipe

", + "translation": "

一个非纯而且带缓存的管道

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" + }, { "original": "Write one more impure pipe, a pipe that makes an HTTP request.", "translation": "我们来写更多的非纯管道:一个向服务器发起HTTP请求的管道。", @@ -17104,6 +17404,11 @@ "translation": "[JsonPipe](api/common/JsonPipe)为你诊断数据绑定的某些神秘错误或为做进一步绑定而探查数据时,提供了一个简单途径。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" }, + { + "original": "

Pure pipes and pure functions

", + "translation": "### 纯管道与纯函数", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/pipes.md" + }, { "original": "A pure pipe uses pure functions.\nPure functions process inputs and return values without detectable side effects.\nGiven the same input, they should always return the same output.", "translation": "纯管道使用纯函数。\n纯函数是指在处理输入并返回结果时,不会产生任何副作用的函数。\n给定相同的输入,它们总是返回相同的输出。", @@ -17209,6 +17514,11 @@ "translation": "你还可以 下载这个例子 。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" }, + { + "original": "

\n Step 1. Set up the Development Environment\n

", + "translation": "

\n 步骤1. 设置开发环境\n

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" + }, { "original": "You need to set up your development environment before you can do anything.", "translation": "在开始工作之前,我们必须设置好开发环境。", @@ -17229,6 +17539,11 @@ "translation": "然后全局安装 **[Angular CLI](https://github.com/angular/angular-cli)** 。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" }, + { + "original": "

\n Step 2. Create a new project\n

", + "translation": "

\n 步骤2. 创建新项目\n

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" + }, { "original": "Open a terminal window.", "translation": "打开终端窗口。", @@ -17244,6 +17559,11 @@ "translation": "请耐心等待。\n创建新项目需要花费很多时间,大多数时候都是在安装那些npm包。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" }, + { + "original": "

\n Step 3: Serve the application\n

", + "translation": "

\n 步骤3. 启动开发服务器\n

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" + }, { "original": "Go to the project directory and launch the server.", "translation": "进入项目目录,并启动服务器。", @@ -17264,6 +17584,11 @@ "translation": "本应用会用一条消息来跟你打招呼:", "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" }, + { + "original": "

\n Step 4: Edit your first Angular component\n

", + "translation": "

\n 步骤4. 编辑我们的第一个Angular组件\n

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" + }, { "original": "The CLI created the first Angular component for you.\nThis is the _root component_ and it is named `app-root`.\nYou can find it in `./src/app/app.component.ts`.", "translation": "这个CLI为我们创建了第一个Angular组件。\n它就是名叫`app-root`的*根组件*。\n你可以在`./src/app/app.component.ts`目录下找到它。", @@ -17340,12 +17665,12 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" }, { - "original": "File", + "original": "
\n Feature", "translation": "特性", "sourceFile": "/Users/twer/private/GDE/content-1/guide/browser-support.md" }, { - "original": "Polyfill", + "original": "\n Polyfill", "translation": "填充库", "sourceFile": "/Users/twer/private/GDE/content-1/guide/browser-support.md" }, { - "original": "Browsers (Desktop & Mobile)", + "original": "\n Browsers (Desktop & Mobile)", "translation": "浏览器(桌面和移动)", "sourceFile": "/Users/twer/private/GDE/content-1/guide/browser-support.md" }, { - "original": "[Animations](guide/animations)", + "original": "\n [Animations](guide/animations)", "translation": "[动画](guide/animations)", "sourceFile": "/Users/twer/private/GDE/content-1/guide/browser-support.md" }, { "original": "[Web Animations](guide/browser-support#web-animations)", - "translation": "[Web 动画](guide/browser-support#web-animations)", + "translation": "[Web 动画](guide/browser-support#web-animations)\n
\n \n \n \n \n \n \n \n \n \n \n \n
\n File", "translation": "文件", "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" }, { - "original": "Purpose", + "original": "\n Purpose", "translation": "用途", "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" }, @@ -17361,7 +17686,7 @@ }, { "original": "A folder where you can put images and anything else to be copied wholesale\n when you build your application.", - "translation": "这个文件夹下你可以放图片等任何东西,在构建应用时,它们全都会拷贝到发布包中。", + "translation": "这个文件夹下你可以放图片等任何东西,在构建应用时,它们全都会拷贝到发布包中。\n \n
", "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" }, { @@ -17371,7 +17696,7 @@ }, { "original": "Every site wants to look good on the bookmark bar.\n Get started with your very own Angular icon.", - "translation": "每个网站都希望自己在书签栏中能好看一点。\n 请把它换成你自己的图标。", + "translation": "每个网站都希望自己在书签栏中能好看一点。\n 请把它换成你自己的图标。\n
", "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" }, { @@ -17415,12 +17740,12 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" }, { - "original": "File", + "original": "\n \n \n \n \n \n \n
\n File", "translation": "文件", "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" }, { - "original": "Purpose", + "original": "\n Purpose", "translation": "用途", "sourceFile": "/Users/twer/private/GDE/content-1/guide/quickstart.md" }, @@ -18126,17 +18451,17 @@ }, { "original": "the value of a `FormControl`.", - "translation": "`FormControl`的值。", + "translation": "`FormControl`的值。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/reactive-forms.md" }, { "original": "the validity of a `FormControl`. Possible values: `VALID`,\n `INVALID`, `PENDING`, or `DISABLED`.", - "translation": "`FormControl`的有效性。可能的值有`VALID`、`INVALID`、`PENDING`或`DISABLED`。", + "translation": "`FormControl`的有效性。可能的值有`VALID`、`INVALID`、`PENDING`或`DISABLED`。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/reactive-forms.md" }, { "original": "`true` if the user has _not_ changed the value in the UI.\n Its opposite is `myControl.dirty`.", - "translation": "如果用户*尚未*改变过这个控件的值,则为`true`。它总是与`myControl.dirty`相反。", + "translation": "如果用户*尚未*改变过这个控件的值,则为`true`。它总是与`myControl.dirty`相反。\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/reactive-forms.md" }, { @@ -19000,23 +19325,23 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { - "original": "Property", - "translation": "属性", + "original": "\n \n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { - "original": "Description", - "translation": "描述", + "original": "\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { "original": "An `Observable` of the route path(s), represented as an array of strings for each part of the route path.", - "translation": "路由路径的`Observable`对象,是一个由路由路径中的各个部分组成的字符串数组。", + "translation": "路由路径的`Observable`对象,是一个由路由路径中的各个部分组成的字符串数组。\n \n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { "original": "An `Observable` that contains the `data` object provided for the route. Also contains any resolved values from the [resolve guard](#resolve-guard).", - "translation": "一个`Observable`,其中包含提供给路由的`data`对象。也包含由[解析守卫(resolve guard)](#resolve-guard)解析而来的值。", + "translation": "一个`Observable`,其中包含提供给路由的`data`对象。也包含由[解析守卫(resolve guard)](#resolve-guard)解析而来的值。\n \n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { @@ -19031,7 +19356,7 @@ }, { "original": "The name of the `RouterOutlet` used to render the route. For an unnamed outlet, the outlet name is _primary_.", - "translation": "要把该路由渲染到的`RouterOutlet`的名字。对于无名路由,它的路由名是`primary`,而不是空串。", + "translation": "要把该路由渲染到的`RouterOutlet`的名字。对于无名路由,它的路由名是`primary`,而不是空串。\n \n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { @@ -19041,7 +19366,7 @@ }, { "original": "The route's parent `ActivatedRoute` when this route is a [child route](#child-routing-component).", - "translation": "当该路由是一个[子路由](#child-routing-component)时,表示该路由的父级`ActivatedRoute`。", + "translation": "当该路由是一个[子路由](#child-routing-component)时,表示该路由的父级`ActivatedRoute`。\n \n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { @@ -19080,12 +19405,12 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { - "original": "Router Event", + "original": "
\n Property", + "translation": "属性\n \n Description", + "translation": "描述\n
\n \n
\n Router Event", "translation": "路由器事件", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { - "original": "Description", + "original": "\n Description", "translation": "描述", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, @@ -19155,13 +19480,18 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { - "original": "Displays the application component for the active URL.\n Manages navigation from one component to the next.", - "translation": "为激活的URL显示应用组件。管理从一个组件到另一个组件的导航", + "original": "Router", + "translation": "Router(路由器)", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { - "original": "A separate NgModule that provides the necessary service providers\n and directives for navigating through application views.", - "translation": "一个独立的Angular模块,用于提供所需的服务提供商,以及用来在应用视图之间进行导航的指令。", + "original": "RouterModule", + "translation": "RouterModule(路由器模块)", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" + }, + { + "original": "Routes", + "translation": "Routes(路由数组)", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { @@ -19170,8 +19500,13 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { - "original": "Defines how the router should navigate to a component based on a URL pattern.\n Most routes consist of a path and a component type.", - "translation": "定义路由器该如何根据URL模式(pattern)来导航到组件。大多数路由都由路径和组件类构成。", + "original": "Route", + "translation": "Route(路由)", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" + }, + { + "original": "RouterOutlet", + "translation": "RouterOutlet(路由出口)", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { @@ -19180,28 +19515,38 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { - "original": "The directive for binding a clickable HTML element to\n a route. Clicking an element with a routerLink directive\n that is bound to a link parameters array triggers a navigation.", - "translation": "该指令用来把一个可点击的HTML元素绑定到路由。\n 点击带有绑定到字符串链接参数数组routerLink指令的元素就会触发一次导航。", + "original": "RouterLink", + "translation": "RouterLink(路由链接)", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { - "original": "The directive for adding/removing classes from an HTML element when an associated\n routerLink contained on or inside the element becomes active/inactive.", - "translation": "当HTML元素上或元素内的routerLink变为激活或非激活状态时,该指令为这个HTML元素添加或移除CSS类。", + "original": "RouterLinkActive", + "translation": "RouterLinkActive(活动路由链接)", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { - "original": "A service that is provided to each route component that contains route specific\n information such as route parameters, static data, resolve data, global query params, and the global fragment.", - "translation": "为每个路由组件提供提供的一个服务,它包含特定于路由的信息,比如路由参数、静态数据、解析数据、全局查询参数和全局碎片(fragment)。", + "original": "ActivatedRoute", + "translation": "ActivatedRoute(激活的路由)", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { - "original": "The current state of the router including a tree of the currently activated\n routes together with convenience methods for traversing the route tree.", - "translation": "路由器的当前状态包含了一棵由程序中激活的路由构成的树。它包含一些用于遍历路由树的快捷方法。", + "original": "RouterState", + "translation": "RouterState(路由器状态)", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { - "original": "An array that the router interprets as a routing instruction.\n You can bind that array toa RouterLink or pass the array as an argument to\n the Router.navigate method.", - "translation": "这个数组会被路由器解释成一个路由操作指南。我们可以把一个RouterLink绑定到该数组,或者把它作为参数传给Router.navigate方法。", + "original": "Link parameters array", + "translation": "链接参数数组", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" + }, + { + "original": "Routing component", + "translation": "路由组件", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" + }, + { + "original": "An Angular component with a RouterOutlet that displays views based on router navigations.", + "translation": "一个带有RouterOutlet的Angular组件,它根据路由器的导航来显示相应的视图。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { @@ -20290,23 +20635,23 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { - "original": "Member", - "translation": "成员", + "original": "\n \n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { - "original": "Description", - "translation": "描述", + "original": "\n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { "original": "Returns `true` if the parameter name is in the map of parameters.", - "translation": "如果参数名位于参数列表中,就返回 `true` 。", + "translation": "如果参数名位于参数列表中,就返回 `true` 。\n \n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { "original": "Returns the parameter name value (a `string`) if present, or `null` if the parameter name is not in the map. Returns the _first_ element if the parameter value is actually an array of values.", - "translation": "如果这个map中有参数名对应的参数值(字符串),就返回它,否则返回`null`。如果参数值实际上是一个数组,就返回它的*第一个*元素。", + "translation": "如果这个map中有参数名对应的参数值(字符串),就返回它,否则返回`null`。如果参数值实际上是一个数组,就返回它的*第一个*元素。\n \n ", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { @@ -21701,7 +22046,7 @@ }, { "original": "Now you have given the user a safeguard against unsaved changes.", - "translation": "现在,我们已经给了用户一个能保护未保存更改的安全守卫。\n{@a Resolve}", + "translation": "现在,我们已经给了用户一个能保护未保存更改的安全守卫。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { @@ -22345,7 +22690,7 @@ "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, { - "original": "where you can download the final source code.", + "original": "You've covered a lot of ground in this guide and the application is too big to reprint here.\nPlease visit the \nwhere you can download the final source code.", "translation": "本章中涉及到了很多背景知识,而且本应用程序也太大了,所以没法在这里显示。请访问,在那里你可以下载最终的源码。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/router.md" }, @@ -22634,6 +22979,11 @@ "translation": "运行来试用本页的代码。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/security.md" }, + { + "original": "

\nReporting vulnerabilities\n

", + "translation": "

\n举报漏洞\n

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/security.md" + }, { "original": "To report vulnerabilities in Angular itself, email us at [security@angular.io](mailto:security@angular.io).", "translation": "给我们([security@angular.io](mailto:security@angular.io))发邮件,报告Angular本身的漏洞。", @@ -22644,6 +22994,11 @@ "translation": "要了解关于“谷歌如何处理安全问题”的更多信息,参见[谷歌的安全哲学](https://www.google.com/about/appsecurity/)。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/security.md" }, + { + "original": "

\nBest practices\n

", + "translation": "

\n最佳实践\n

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/security.md" + }, { "original": "* **Keep current with the latest Angular library releases.**\nWe regularly update the Angular libraries, and these updates may fix security defects discovered in\nprevious versions. Check the Angular [change\nlog](https://github.com/angular/angular/blob/master/CHANGELOG.md) for security-related updates.", "translation": "**及时把Angular包更新到最新版本。**\n我们会频繁的更新Angular库,这些更新可能会修复之前版本中发现的安全漏洞。查看Angular的[更新记录](https://github.com/angular/angular/blob/master/CHANGELOG.md),了解与安全有关的更新。", @@ -22794,6 +23149,11 @@ "translation": "服务器端构造的HTML很容易受到注入攻击。当需要在服务器端生成HTML时(比如Angular应用的初始页面),\n 务必使用一个能够自动进行无害化处理以防范XSS漏洞的后端模板语言。不要在服务器端使用模板语言生成Angular模板,\n 这样会带来很高的“模板注入”风险。", "sourceFile": "/Users/twer/private/GDE/content-1/guide/security.md" }, + { + "original": "

\n Trusting safe values\n

", + "translation": "

\n 信任安全值\n

", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/security.md" + }, { "original": "Sometimes applications genuinely need to include executable code, display an `
\n Member", + "translation": "成员\n \n Description", + "translation": "描述\n