第二节翻译了一部分

This commit is contained in:
Zhicheng Wang 2016-04-13 19:34:31 +08:00
parent b2eea2e20e
commit 3e89409212
2 changed files with 17 additions and 2 deletions

View File

@ -281,6 +281,7 @@ code-example(format="").
a(id="app-component")
:marked
**Add a component file** named *app.component.ts* and paste the following lines:
**添加一个组件文件** ,命名为 *app.component.ts* 并粘贴下列代码:
+makeExample('quickstart/ts/app/app.component.ts', null, 'app/app.component.ts')(format=".")

View File

@ -23,11 +23,13 @@ include ../_util-fns
.l-main-section
:marked
## Where We Left Off
##
## 我们刚刚到哪儿了
Before we continue with Part 2 of the Tour of Heroes,
lets verify we have the following structure after [Part 1](./toh-pt1.html).
If not, well need to go back to Part 1 and figure out what we missed.
在继续《英雄之旅》的第二部分之前,我们先检查一下,完成第一部分之后,你是否已经有了如下目录结构,如果没有,你得先回到第一部分,看看缺了哪里。
.filetree
.file angular2-tour-of-heroes
.children
@ -43,7 +45,10 @@ include ../_util-fns
.file typings.json
:marked
### Keep the app transpiling and running
### 让应用代码保持转译和运行
We want to start the TypeScript compiler, have it watch for changes, and start our server. We'll do this by typing
我们要启动TypeScript编译器它会监视文件变更并且启动开发服务器。我们只要敲
code-example(format="." language="bash").
npm start
@ -51,13 +56,19 @@ code-example(format="." language="bash").
:marked
This will keep the application running while we continue to build the Tour of Heroes.
这个命令会在我们构建《英雄之旅》的时候让应用得以持续运行。
.l-main-section
:marked
## Displaying Our Heroes
## 展示我们的英雄
### Creating heroes
### 创建英雄
Lets create an array of ten heroes at the bottom of `app.component.ts`.
我们先在`app.component.ts`的底部创建一个由十位英雄组成的数组。
+makeExample('toh-2/ts/app/app.component.ts', 'hero-array', 'app.component.ts (Hero array)')
+makeExample('toh-2/ts/app/app.component.ts', 'hero-array', 'app.component.ts (英雄数组)')
:marked
The `HEROES` array is of type `Hero`, the class defined in part one,
@ -65,6 +76,9 @@ code-example(format="." language="bash").
We aspire to fetch this list of heroes from a web service, but lets take small steps
first and display mock heroes.
`HEROS`变量是一个由`Hero`类的实例构成的数组,我们在第一部分定义过它。
我们当然希望从一个Web服务中获取这个英雄列表但是不要急我们得把步子迈得小一点 —— 先用一组Mock模拟对象出来的英雄。
### Exposing heroes
Lets create a property in `AppComponent` that exposes the heroes for binding.