diff --git a/aio/content/translations/cn/api-plan.md b/aio/content/translations/cn/api-plan.md index eb42001a7a..285fc730c6 100644 --- a/aio/content/translations/cn/api-plan.md +++ b/aio/content/translations/cn/api-plan.md @@ -48,7 +48,7 @@ [x] | platform-browser/BrowserModule | 0.40 [x] | common/DecimalPipe | 0.40 [x] | common/CurrencyPipe | 0.39 -[ ] | router/RouterLinkActive | 0.38 +[x] | router/RouterLinkActive | 0.38 [ ] | core/TemplateRef | 0.38 [ ] | forms/FormBuilder | 0.37 [ ] | common/http/HttpParams | 0.35 diff --git a/packages/router/src/directives/router_link_active.ts b/packages/router/src/directives/router_link_active.ts index 2953fafc5a..b94d519b6c 100644 --- a/packages/router/src/directives/router_link_active.ts +++ b/packages/router/src/directives/router_link_active.ts @@ -21,11 +21,17 @@ import {RouterLink, RouterLinkWithHref} from './router_link'; * * Lets you add a CSS class to an element when the link's route becomes active. * + * 当此链接指向的路由激活时,往宿主元素上添加一个 CSS 类。 + * * This directive lets you add a CSS class to an element when the link's route * becomes active. * + * 当此链接指向的路由激活时,该指令就会往宿主元素上添加一个 CSS 类。 + * * Consider the following example: * + * 考虑下面的例子: + * * ``` * Bob * ``` @@ -33,8 +39,13 @@ import {RouterLink, RouterLinkWithHref} from './router_link'; * When the url is either '/user' or '/user/bob', the active-link class will * be added to the `a` tag. If the url changes, the class will be removed. * + * 当浏览器的当前 url 是 '/user' 或 '/user/bob' 时,就会往 `a` 标签上添加 `active-link` 类; + * 如果 url 发生了变化,则移除它。 + * * You can set more than one class, as follows: * + * 你可以设置一个或多个类,例如: + * * ``` * Bob * Bob @@ -43,6 +54,8 @@ import {RouterLink, RouterLinkWithHref} from './router_link'; * You can configure RouterLinkActive by passing `exact: true`. This will add the classes * only when the url matches the link exactly. * + * 你可以通过传入 `exact: true` 来配置 RouterLinkActive。这样,只有当 url 和此链接精确匹配时才会添加这些类。 + * * ``` * Bob @@ -50,6 +63,9 @@ import {RouterLink, RouterLinkWithHref} from './router_link'; * * You can assign the RouterLinkActive instance to a template variable and directly check * the `isActive` status. + * + * 你可以把 `RouterLinkActive` 的实例赋给一个模板变量,以直接检查 `isActive` 的状态。 + * * ``` * * Bob {{ rla.isActive ? '(already open)' : ''}} @@ -58,8 +74,10 @@ import {RouterLink, RouterLinkWithHref} from './router_link'; * * Finally, you can apply the RouterLinkActive directive to an ancestor of a RouterLink. * + * 最后,你还可以把 `RouterLinkActive` 指令用在 `RouterLink` 的各级祖先节点上。 + * * ``` - *
+ *
* Jim * Bob *
@@ -68,6 +86,8 @@ import {RouterLink, RouterLinkWithHref} from './router_link'; * This will set the active-link class on the div tag if the url is either '/user/jim' or * '/user/bob'. * + * 这样,无论当前 url 是 '/user/jim' 还是 '/user/bob',都会往 `div` 标签上添加一个 `active-link` 类。 + * * @ngModule RouterModule * *