fix toh-pt6.jade translation according to comment

This commit is contained in:
baiyangcao 2017-03-12 23:42:27 +08:00
parent f7a270e78a
commit 4d352b3de8
1 changed files with 15 additions and 15 deletions

View File

@ -353,14 +353,14 @@ block get-heroes-details
That's fine in a simulation. It's wasteful to ask a real server for _all_ heroes when we only want one. That's fine in a simulation. It's wasteful to ask a real server for _all_ heroes when we only want one.
Most web APIs support a _get-by-id_ request in the form `api/hero/:id` (e.g., `api/hero/11`). Most web APIs support a _get-by-id_ request in the form `api/hero/:id` (e.g., `api/hero/11`).
现有`HeroService`可以通过获取所有英雄,然后根据`id`来过滤出想要的英雄,对于例子来说这无可厚非, HeroService现在会获取所有英雄再根据id来过滤出想要的英雄这对于例子来说倒是无可厚非,
但是若到真实服务的时候,这种为了获取一个英雄而请求全部英雄的做法就有点浪费了, 不过在真实服务中,这种为了获取一个英雄而请求全部英雄的做法就有点浪费了,
许多Web API支持_get-by-id_请求,形如:`api/hero/:id`(如:`api/hero/11`)。 许多Web API支持*get-by-id*请求,形如:`api/hero/:id`(如:`api/hero/11`)。
Update the `HeroService.getHero` method to make a _get-by-id_ request, Update the `HeroService.getHero` method to make a _get-by-id_ request,
applying what we just learned to write `getHeroes`: applying what we just learned to write `getHeroes`:
使用我们刚刚编写`getHeroes`所学的方法,更新`HeroService.getHero`方法制作一个_get-by-id_请求: 使用我们编写 `getHeroes` 时刚刚学到的方法,修改 `HeroService.getHero` 方法来发起一个 *get-by-id* 请求:
+makeExcerpt('src/app/hero.service.ts', 'getHero', '') +makeExcerpt('src/app/hero.service.ts', 'getHero', '')
:marked :marked
@ -373,7 +373,7 @@ block get-heroes-details
We also adjust to the fact that the `data` in the response is a single hero object rather than !{_an} !{_array}. We also adjust to the fact that the `data` in the response is a single hero object rather than !{_an} !{_array}.
我们还要调整响应返回的`data`为一个英雄对象,而不是一个对象数组。 我们还要把响应中返回的`data`改为一个英雄对象,而不再是对象数组。组。
### Unchanged _getHeroes_ API ### Unchanged _getHeroes_ API
@ -384,9 +384,9 @@ block get-heroes-details
We still return a !{_Promise} from both methods. We still return a !{_Promise} from both methods.
We won't have to update any of the components that call them. We won't have to update any of the components that call them.
尽管我们在`getHeroes()`和`getHero()`方法的*内部*做了重大改 尽管我们在`getHeroes()`和`getHero()`方法的*内部*做了重大改,
但是他们的公共签名却没有变。这两个方法仍然返回的是一个!{Promise}对象, 但是他们的公共签名却没有变。这两个方法仍然返回的是一个!{Promise}对象,
所以并不需要更新任何调用他们的组件。 所以并不需要修改任何调用他们的组件。
Our stakeholders are thrilled with the web API integration so far. Our stakeholders are thrilled with the web API integration so far.
Now they want the ability to create and delete heroes. Now they want the ability to create and delete heroes.
@ -675,8 +675,8 @@ block observables-section-intro
after chaining it to another RxJS operator, <code>map</code>, after chaining it to another RxJS operator, <code>map</code>,
to extract heroes from the response data. to extract heroes from the response data.
更重要的不同:我们不再调用`toPromise`方法,而是从`http.get` 更重要的:我们不再调用`toPromise`方法,而是从`http.get`
方法中返回一个*Observable*对象,之后链式调用RxJS操作<code>map</code> 方法中返回一个*Observable*对象,之后调用RxJS的<code>map</code>操作符
来从返回数据中提取英雄。 来从返回数据中提取英雄。
RxJS operator chaining makes response processing easy and readable. RxJS operator chaining makes response processing easy and readable.
@ -849,13 +849,13 @@ block observable-transformers
Most RxJS operators are not included in Angular's base `Observable` implementation. Most RxJS operators are not included in Angular's base `Observable` implementation.
The base implementation includes only what Angular itself requires. The base implementation includes only what Angular itself requires.
大部分RxJS操作符不包括在Angular的`Observable`基本实现中,基本实现只包括Angular本身所需的功能。 大部分RxJS操作符不包括在Angular的`Observable`基本实现中基本实现只包括Angular本身所需的功能。
If we want more RxJS features, we have to extend `Observable` by *importing* the libraries in which they are defined. If we want more RxJS features, we have to extend `Observable` by *importing* the libraries in which they are defined.
Here are all the RxJS imports _this_ component needs: Here are all the RxJS imports _this_ component needs:
如果想要更多的RxJS功能我们必须通过*导入*其所定义的库来扩展`Observable`对象, 如果想要更多的RxJS功能我们必须*导入*其所定义的库来扩展`Observable`对象,
以下是_这个_模块所需导入的所有RxJS操作 以下是*这个*模块所需导入的所有RxJS操作符
+makeExample('src/app/hero-search.component.ts','rxjs-imports','src/app/hero-search.component.ts (rxjs imports)')(format='.') +makeExample('src/app/hero-search.component.ts','rxjs-imports','src/app/hero-search.component.ts (rxjs imports)')(format='.')
@ -863,14 +863,14 @@ block observable-transformers
The `import 'rxjs/add/...'` syntax may be unfamiliar. The `import 'rxjs/add/...'` syntax may be unfamiliar.
It's missing the usual list of symbols between the braces: `{...}`. It's missing the usual list of symbols between the braces: `{...}`.
你可能并不熟悉`import 'rxjs/add/...'`语法,缺少了括号之间的导入列表:`{...}`。 你可能并不熟悉这种`import 'rxjs/add/...'`语法,它缺少了花括号中的导入列表:`{...}`。
We don't need the operator symbols themselves. We don't need the operator symbols themselves.
In each case, the mere act of importing the library In each case, the mere act of importing the library
loads and executes the library's script file which, in turn, adds the operator to the `Observable` class. loads and executes the library's script file which, in turn, adds the operator to the `Observable` class.
其实我们并不需要操作符本身,正常情况下,导入库不过是加载和执行库所对应的脚本文件 这是因为我们并不需要操作符本身,这种情况下,我们所做的其实是导入这个库,加载并运行其中的脚本
然后依次将操作符作为方法添加到`Observable`类中。 它会把操作符添加到`Observable`类中。
:marked :marked
### Add the search component to the dashboard ### Add the search component to the dashboard