diff --git a/public/_includes/_footer.jade b/public/_includes/_footer.jade index 1983cd190b..7eac42c6e2 100644 --- a/public/_includes/_footer.jade +++ b/public/_includes/_footer.jade @@ -68,7 +68,7 @@ else h3.text-headline 其它语种 ul.text-body - li 英文版 + li English footer(class="background-steel") p diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/hero.service.ts b/public/docs/_examples/cb-dependency-injection/ts/app/hero.service.ts index 9a7bdccd02..2063c30d7a 100644 --- a/public/docs/_examples/cb-dependency-injection/ts/app/hero.service.ts +++ b/public/docs/_examples/cb-dependency-injection/ts/app/hero.service.ts @@ -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 { diff --git a/public/docs/_examples/router-deprecated/ts/app/crisis-center/crisis.service.ts b/public/docs/_examples/router-deprecated/ts/app/crisis-center/crisis.service.ts index 1200e8ac31..a847a15217 100644 --- a/public/docs/_examples/router-deprecated/ts/app/crisis-center/crisis.service.ts +++ b/public/docs/_examples/router-deprecated/ts/app/crisis-center/crisis.service.ts @@ -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 diff --git a/public/docs/_examples/router-deprecated/ts/app/heroes/hero.service.ts b/public/docs/_examples/router-deprecated/ts/app/heroes/hero.service.ts index c2aec9807e..c819bd2632 100644 --- a/public/docs/_examples/router-deprecated/ts/app/heroes/hero.service.ts +++ b/public/docs/_examples/router-deprecated/ts/app/heroes/hero.service.ts @@ -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)); } } diff --git a/public/docs/_examples/router/ts/app/crisis-center/crisis.service.ts b/public/docs/_examples/router/ts/app/crisis-center/crisis.service.ts index 20597752cc..b5d9e282c0 100644 --- a/public/docs/_examples/router/ts/app/crisis-center/crisis.service.ts +++ b/public/docs/_examples/router/ts/app/crisis-center/crisis.service.ts @@ -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 diff --git a/public/docs/_examples/router/ts/app/heroes/hero.service.ts b/public/docs/_examples/router/ts/app/heroes/hero.service.ts index c2aec9807e..6e4e7bee60 100644 --- a/public/docs/_examples/router/ts/app/heroes/hero.service.ts +++ b/public/docs/_examples/router/ts/app/heroes/hero.service.ts @@ -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)); } } diff --git a/public/docs/_examples/testing/ts/app/hero.service.ts b/public/docs/_examples/testing/ts/app/hero.service.ts index f83588934b..e9473e4038 100644 --- a/public/docs/_examples/testing/ts/app/hero.service.ts +++ b/public/docs/_examples/testing/ts/app/hero.service.ts @@ -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 diff --git a/public/docs/_examples/toh-5/ts/app/hero.service.ts b/public/docs/_examples/toh-5/ts/app/hero.service.ts index c1cb8fa3e6..900d0da712 100644 --- a/public/docs/_examples/toh-5/ts/app/hero.service.ts +++ b/public/docs/_examples/toh-5/ts/app/hero.service.ts @@ -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 } diff --git a/public/docs/_examples/toh-6/ts/app/hero.service.ts b/public/docs/_examples/toh-6/ts/app/hero.service.ts index 8995a3dd96..a2344d84e6 100644 --- a/public/docs/_examples/toh-6/ts/app/hero.service.ts +++ b/public/docs/_examples/toh-6/ts/app/hero.service.ts @@ -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 diff --git a/public/docs/ts/latest/guide/router.jade b/public/docs/ts/latest/guide/router.jade index 43240b62b5..b9ac913b08 100644 --- a/public/docs/ts/latest/guide/router.jade +++ b/public/docs/ts/latest/guide/router.jade @@ -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. diff --git a/public/translate/cn/follow.jade b/public/translate/cn/follow.jade index a976d06a80..9ac5c4af8f 100644 --- a/public/translate/cn/follow.jade +++ b/public/translate/cn/follow.jade @@ -2,9 +2,7 @@ :marked ## 官方论坛 - - [bbs.angular.cn](https://bbs.angular.cn) - - 本论坛正在建设中,稍显简陋,我们明年会发布一个更好的版本并开源。 + - **[bbs.angular.cn](https://bbs.angular.cn)** 本论坛正在建设中,我们明年会发布一个更好的版本并开源。 ## 官方微信 diff --git a/public/translate/cn/home.jade b/public/translate/cn/home.jade index 94e3103d24..6255f0b3dd 100644 --- a/public/translate/cn/home.jade +++ b/public/translate/cn/home.jade @@ -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)。