Merge branch 'master' of https://github.com/angular/angular-cn into dreamapple-contribute

This commit is contained in:
dreamapple 2016-07-04 09:09:03 +08:00
commit 28b101e402
12 changed files with 45 additions and 24 deletions

View File

@ -68,7 +68,7 @@ else
h3.text-headline 其它语种
ul.text-body
li <a href="https://angular.io/" target="_blank">英文版</a>
li <a href="https://angular.io/" target="_blank">English</a>
footer(class="background-steel")
p

View File

@ -13,7 +13,7 @@ export class HeroService {
];
getHeroById(id: number): Hero {
return this.heroes.filter(hero => hero.id === id)[0];
return this.heroes.find(hero => hero.id === id);
}
getAllHeroes(): Array<Hero> {

View File

@ -21,7 +21,7 @@ export class CrisisService {
getCrisis(id: number | string) {
return crisesPromise
.then(crises => crises.filter(c => c.id === +id)[0]);
.then(crises => crises.find(c => c.id === +id));
}
// #enddocregion

View File

@ -22,6 +22,6 @@ export class HeroService {
getHero(id: number | string) {
return heroesPromise
.then(heroes => heroes.filter(h => h.id === +id)[0]);
.then(heroes => heroes.find(h => h.id === +id));
}
}

View File

@ -25,7 +25,7 @@ export class CrisisService {
getCrisis(id: number | string) {
return crisesPromise
.then(crises => crises.filter(c => c.id === +id)[0]);
.then(crises => crises.find(crisis => crisis.id === +id));
}
// #enddocregion

View File

@ -22,6 +22,6 @@ export class HeroService {
getHero(id: number | string) {
return heroesPromise
.then(heroes => heroes.filter(h => h.id === +id)[0]);
.then(heroes => heroes.find(hero => hero.id === +id));
}
}

View File

@ -20,7 +20,7 @@ export class HeroService {
// #docregion get-hero
getHero(id: number) {
return Promise.resolve(HEROES).then(
heroes => heroes.filter(hero => hero.id === id)[0]
heroes => heroes.find(hero => hero.id === id)
);
}
// #enddocregion get-hero

View File

@ -20,7 +20,7 @@ export class HeroService {
// #docregion get-hero
getHero(id: number) {
return this.getHeroes()
.then(heroes => heroes.filter(hero => hero.id === id)[0]);
.then(heroes => heroes.find(hero => hero.id === id));
}
// #enddocregion get-hero
}

View File

@ -33,7 +33,7 @@ export class HeroService {
getHero(id: number) {
return this.getHeroes()
.then(heroes => heroes.filter(hero => hero.id === id)[0]);
.then(heroes => heroes.find(hero => hero.id === id));
}
// #docregion save

View File

@ -1226,7 +1226,7 @@ h3#merge-hero-routes 把英雄区的路由合并到应用程序的路由中
把`app.routes.ts`改成这样:
+makeExample('router/ts/app/app.routes.3.ts', '', 'app/app.routes.ts (v.2)')(format=".")
+makeExample('router/ts/app/app.routes.2.ts', '', 'app/app.routes.ts (v.2)')(format=".")
:marked
We replace the `HeroListComponent` import with an `HeroesRoutes` import.
@ -1561,8 +1561,8 @@ h3#nav-to-list 导航回列表组件
这里是当前版本的范例程序相关文件。
+makeTabs(
`router/ts/app/app.component.1.ts,
router/ts/app/app.routes.3.ts,
`router/ts/app/app.component.2.ts,
router/ts/app/app.routes.2.ts,
router/ts/app/heroes/hero-list.component.1.ts,
router/ts/app/heroes/hero-detail.component.1.ts,
router/ts/app/heroes/hero.service.ts,
@ -1896,15 +1896,16 @@ code-example(format="").
当用户点击了“Crisis Center”链接或者在地址栏粘贴`localhost:3000/crisis-center/`时,我们更希望该应用能直接显示危机列表。这就是默认路由。
The preferred solution is to add a `redirect` route that transparently translates from the initial URL (`''`) to the preferred default path (`/crisis-center`):
The preferred solution is to add a `redirect` route that transparently translates from the initial relative URL (`''`)
to the desired default path (`/crisis-center`):
首选的解决方案是添加一个`redirect`路由,它会透明的把初始URL`''`)翻译成默认路径(`/crisis-center`)。
首选的解决方案是添加一个`redirect`路由,它会把初始的相对URL`''`悄悄翻译成默认路径(`/crisis-center`)。
+makeExample('router/ts/app/crisis-center/crisis-center.routes.2.ts', 'redirect', 'app/crisis-center/crisis-center.routes.ts (redirect route)' )(format='.')
:marked
A redirect route requires a `pathMatch` property to tell the router how to match a URL to the path of a route.
In this app, the router should select the route to `CrisisCenterComponent` when the *entire URL* matches `''`,
In this app, the router should select the route to the `CrisisListComponent` when the *entire URL* matches `''`,
so we set the `pathMatch` value to `'full'`.
由于我们希望只有在路径明确的匹配到`''`时才重定向,所以我们往路由中添加了一个额外的配置项:`terminal: true`。
@ -1913,12 +1914,22 @@ code-example(format="").
.l-sub-section
:marked
Technically, `pathMatch = 'full'` results in a route hit when the *remaining*, unmatched segments of the URL match `''`.
In our example, the redirect is at the top level of the route configuration tree so the *remaining* URL and the *entire* URL
are the same thing.
The other possible `pathMatch` value is `'prefix'` which tells the router
to match the redirect route to _any_ URL that _begins_ with the redirect route's _prefix_ path.
to match the redirect route when the *remaining* URL ***begins*** with the redirect route's _prefix_ path.
That's not what we want in our use case. The `''` prefix path matches _every_ URL.
We should redirect to the `CrisisCenterComponent` _only_ when the _entire_ url is `''`
(or the equivalent `'/'`).
That's not what we want to do here. If the `pathMatch` value were `'prefix'`,
_every_ URL would match `''`.
We could never navigate to `/crisis-center/1` because the redirect route would match first and
send us to the `CrisisListComponent`.
We should redirect to the `CrisisListComponent` _only_ when the _entire (remaining)_ url is `''`.
Learn more in Victor Savkin's blog
[post on redirects](http://victorsavkin.com/post/146722301646/angular-router-empty-paths-componentless-routes).
We'll discuss redirects in more detail in a future update to this chapter.

View File

@ -2,9 +2,7 @@
:marked
## 官方论坛
- [bbs.angular.cn](https://bbs.angular.cn)
本论坛正在建设中,稍显简陋,我们明年会发布一个更好的版本并开源。
- **[bbs.angular.cn](https://bbs.angular.cn)** 本论坛正在建设中,我们明年会发布一个更好的版本并开源。
## 官方微信

View File

@ -45,6 +45,11 @@
## 栾跃代表Google大中华区技术推广部(DevRel)的致辞
.l-sub-section
:marked
**这是谷歌开发技术推广部大中华区的主管栾跃发来的致辞。DevRel部门也会安排专人来全职运营Angular中文社区包括组织线上线下的活动、对外合作等。希望大家多多捧场。**
:marked
Hello to Developer Friends of the Angular.CN community!
Angular.CN 社区的开发者朋友们,大家好!
@ -78,10 +83,17 @@
同时要注意我们只翻译“TypeScript”版的文档其它语言的版本大同小异可以在看懂TS版之后再对照看JS和Dart的英文版。不过我们还是建议你试用一下TypeScript。
## 授权方式
本文档遵循[“保持署名—非商用”创意共享4.0许可证CC BY-NC 4.0](http://creativecommons.org/licenses/by-nc/4.0/deed.zh)授权方式,你不用知会我们就可以转载,但必须保持署名(特别是:不得去掉本页入口链接,也不得修改本页内容),并且不得用于商业目的。如果需要进行任何商业推广,请接洽我们的[联系人程路](mailto:lucheng@google.com)。
本文档首发于[Angular中文网](https://angular.cn/)。如果你要进行转载请自行同步不过小心别DDoS了我们。
## 关于中文社区
关于两位译者的简介请参见[这里](./about.html)。
关于Angular中文社区的简介请参见[这里](./follow.html)。
## 工作预告
我们已经组织了一个九人专家组开始了对ng-book2的翻译工作出版社也加快了流程争取能尽早与各位见面以我们一向的质量标准我敢保证这会是一份精品。同时我们也和Google中国的DevRel部门加强了合作未来还会有一系列线上和线下推广工作如果您有意为这些活动贡献力量请接洽我们的[联系人程路](mailto:lucheng@google.com)。
我们已经组织了一个九人专家组开始了对ng-book2的翻译工作出版社也将加快流程,争取能尽早与各位见面。以我们一向的质量标准我敢保证这会是一份精品。同时我们也和Google中国的DevRel部门加强了合作未来还会有一系列线上和线下推广工作如果您有意为这些活动贡献力量请接洽我们的[联系人程路](mailto:lucheng@google.com)。