`内部。
+ 在这个例子中,`[ngClass]="odd"`留在了``上。
+
a#microsyntax
:marked
### Microsyntax
+ ### 微语法
+
The Angular microsyntax lets you configure a directive in a compact, friendly string.
The microsyntax parser translates that string into attributes on the ``:
+ Angular微语法能让我们通过简短的、友好的字符串来配置一个指令。
+ 微语法解析器把这个字符串翻译成``上的属性:
+
* The `let` keyword declares a [_template input variable_](#template-input-variable)
that you reference within the template. The input variables in this example are `hero`, `i`, and `odd`.
The parser translates `let hero`, `let i`, and `let odd` into variables named,
`let-hero`, `let-i`, and `let-odd`.
+ `let`关键字声明一个[模板输入变量](#template-input-variable),我们会在模板中引用它。本例子中,这个输入变量就是`hero`、`i`和`odd`。
+ 解析器会把`let hero`、`let i`和`let odd`翻译成命名变量`let-hero`、`let-i`和`let-odd`。
+
* The microsyntax parser takes `of` and `trackby`, title-cases them (`of` -> `Of`, `trackBy` -> `TrackBy`),
and prefixes them with the directive's attribute name (`ngFor`), yielding the names `ngForOf` and `ngForTrackBy`.
Those are the names of two `NgFor` _input properties_ .
That's how the directive learns that the list is `heroes` and the track-by function is `trackById`.
+ 微语法解析器接收`of`和`trackby`,把它们首字母大写(`of` -> `Of`, `trackBy` -> `TrackBy`),
+ 并且给它们加上指令的属性名(`ngFor`)前缀,最终生成的名字是`ngForOf`和`ngForTrackBy`。
+ 还有两个`NgFor`的*输入属性*,指令据此了解到列表是`heroes`,而track-by函数是`trackById`。
+
* As the `NgFor` directive loops through the list, it sets and resets properties of its own _context_ object.
These properties include `index` and `odd` and a special property named `$implicit`.
+ `NgFor`指令在列表上循环,每个循环中都会设置和重置它自己的*上下文*对象上的属性。
+ 这些属性包括`index`和`odd`以及一个特殊的属性名`$implicit`(隐式变量)。
+
* The `let-i` and `let-odd` variables were defined as `let i=index` and `let odd=odd`.
Angular sets them to the current value of the context's `index` and `odd` properties.
+ `let-i`和`let-odd`变量是通过`let i=index`和`let odd=odd`来定义的。
+ Angular把它们设置为*上下文*对象中的`index`和`odd`属性的当前值。
+
* The context property for `let-hero` wasn't specified.
It's intended source is implicit.
Angular sets `let-hero` to the value of the context's `$implicit` property
which `NgFor` has initialized with the hero for the current iteration.
+ 上下文中的属性`let-hero`没有指定过,实际上它来自一个隐式变量。
+ Angular会把`let-hero`设置为上下文对象中的`$implicit`属性,`NgFor`会用当前迭代中的英雄初始化它。
+
* The [API guide](../api/common/index/NgFor-directive.html "API: NgFor")
describes additional `NgFor` directive properties and context properties.
+ [API参考手册](../api/common/index/NgFor-directive.html "API: NgFor")中描述了`NgFor`指令的其它属性和上下文属性。
+
These microsyntax mechanisms are available to you when you write your own structural directives.
Studying the
[source code for `NgIf`](https://github.com/angular/angular/blob/master/packages/common/src/directives/ng_if.ts "Source: NgIf")
and [`NgFor`](https://github.com/angular/angular/blob/master/packages/common/src/directives/ng_for_of.ts "Source: NgFor")
is a great way to learn more.
+ 这些微语法机制在你写自己的结构型指令时也同样有效,参考[`NgIf`的源码](https://github.com/angular/angular/blob/master/packages/common/src/directives/ng_if.ts "Source: NgIf")
+ 和[`NgFor`的源码](https://github.com/angular/angular/blob/master/packages/common/src/directives/ng_for_of.ts "Source: NgFor") 可以学到更多。
a#template-input-variable
a#template-input-variables
:marked
### Template input variable
+ ### 模板输入变量
+
A _template input variable_ is a variable whose value you can reference _within_ a single instance of the template.
There are several such variables in this example: `hero`, `i`, and `odd`.
All are preceded by the keyword `let`.
+ *模板输入变量*是这样一种变量,你可以*在单个实例的模板中*引用它的值。
+ 这个例子中有好几个模板输入变量:`hero`、`i`和`odd`。
+ 它们都是用`let`作为前导关键字。
+
A _template input variable_ is **_not_** the same as a
[template _reference_ variable](template-syntax.html#ref-vars),
neither _semantically_ nor _syntactically_.
diff --git a/public/docs/ts/latest/guide/typescript-configuration.jade b/public/docs/ts/latest/guide/typescript-configuration.jade
index 5aa4d46b2c..5cbb31702c 100644
--- a/public/docs/ts/latest/guide/typescript-configuration.jade
+++ b/public/docs/ts/latest/guide/typescript-configuration.jade
@@ -55,7 +55,7 @@ a(id="tsconfig")
该文件中的选项和标志是写Angular应用程序的基础。
-a #noImplicitAny
+a#noImplicitAny
:marked
### *noImplicitAny* and *suppressImplicitAnyIndexErrors*
@@ -78,7 +78,7 @@ a #noImplicitAny
The documentation setup sets the `noImplicitAny` flag to `true`.
- [搭建本地开发环境](setup.html)文档将`noImplicitAny`标志设置为`true`。
+ 本文档在环境搭建时将`noImplicitAny`标志设置为`true`。
When the `noImplicitAny` flag is `true` and the TypeScript compiler cannot infer
the type, it still generates the JavaScript files, but it also **reports an error**.
@@ -107,6 +107,8 @@ code-example(format=".").
:marked
The documentation setup sets this flag to `true` as well.
+ 本文档在环境搭建时将`noImplicitAny`标志设置为`true`。
+
a(id="typings")
.l-main-section
:marked
@@ -165,6 +167,8 @@ code-example(format=".").
:marked
Thanks to that, you have all the `es6` typings even when targeting `es5`.
+ 得益于这项设置,即使编译目标设置为`es5`,我们也能获得所有的`es6`类型信息。
+
### Installable typings files
### 安装类型定义文件
@@ -180,7 +184,12 @@ code-example(format=".").
[`@types/*` scoped package](http://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html)
and Typescript, starting at 2.0, automatically recognizes them.
+ 我们还可以通过`npm`来使用[`@types/*`范围化包](http://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html)来安装这些类型信息,
+ 而TypeScript自从2.0开始,可以自动识别它们。
+
For instance, to install typings for `jasmine` you could do `npm install @types/jasmine --save-dev`.
+
+ 比如,要安装`jasmine`的类型信息,我们可以执行`npm install @types/jasmine --save-dev`。
:marked
QuickStart identifies two *typings*, or `d.ts`, files: