| Routing and navigation
路由与导航
 | <p><code>import { Routes, RouterModule, ... } from '@angular/router';</code>
 | 
| <code>const routes: <b>Routes</b> = [<br>  { path: '', component: HomeComponent },<br>  { path: 'path/:routeParam', component: MyComponent },<br>  { path: 'staticPath', component: ... },<br>  { path: '**', component: ... },<br>  { path: 'oldPath', redirectTo: '/staticPath' },<br>  { path: ..., component: ..., data: { message: 'Custom' } }<br>]);<br><br>const routing = RouterModule.forRoot(routes);</code>
 | <p>Configures routes for the application. Supports static, parameterized, redirect, and wildcard routes. Also supports custom route data and resolve.</p>
<p>为该应用配置路由。支持静态、参数化、重定向和通配符路由。也支持自定义路由数据和解析(resolve)函数。</p>
 | 
| <code><br><<b>router-outlet</b>></<b>router-outlet</b>><br><<b>router-outlet</b> name="aux"></<b>router-outlet</b>><br></code>
 | <p>Marks the location to load the component of the active route.</p>
<p>标记出一个位置,用来加载活动路由的组件。</p>
 | 
| <code><br><a routerLink="/path"><br><a <b>[routerLink]</b>="[ '/path', routeParam ]"><br><a <b>[routerLink]</b>="[ '/path', { matrixParam: 'value' } ]"><br><a <b>[routerLink]</b>="[ '/path' ]" [queryParams]="{ page: 1 }"><br><a <b>[routerLink]</b>="[ '/path' ]" fragment="anchor"><br></code>
 | <p>Creates a link to a different view based on a route instruction consisting of a route path, required and optional parameters, query parameters, and a fragment. To navigate to a root route, use the <code>/</code> prefix; for a child route, use the <code>./</code>prefix; for a sibling or parent, use the <code>../</code> prefix.</p>
<p>使用路由体系创建一个到其它视图的链接。路由体系由路由路径、必要参数、可选参数、查询参数和文档片段组成。要导航到根路由,请使用<code>/</code>前缀;要导航到子路由,使用<code>./</code>前缀;要导航到兄弟路由或父级路由,使用<code>../</code>前缀。</p>
 | 
| <code><a [routerLink]="[ '/path' ]" routerLinkActive="active"></code>
 | <p>The provided classes are added to the element when the <code>routerLink</code> becomes the current active route.</p>
<p>当 <code>routerLink</code> 指向的路由变成活动路由时,为当前元素添加一些类(比如这里的 <code>active</code>)。</p>
 | 
| <code>class <b>CanActivate</b>Guard implements <b>CanActivate</b> {<br>    canActivate(<br>      route: ActivatedRouteSnapshot,<br>      state: RouterStateSnapshot<br>    ): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean|UrlTree { ... }<br>}<br><br>{ path: ..., canActivate: [<b>CanActivate</b>Guard] }</code>
 | <p>An interface for defining a class that the router should call first to determine if it should activate this component. Should return a boolean|UrlTree or an Observable/Promise that resolves to a boolean|UrlTree.</p>
<p>用来定义类的接口。路由器会首先调用本接口来决定是否激活该路由。应该返回一个 <code>boolean|UrlTree</code> 或能解析成 <code>boolean|UrlTree</code> 的 <code>Observable/Promise</code>。</p>
 | 
| class CanDeactivateGuard implements CanDeactivate<T> {canDeactivate(
 component: T,
 route: ActivatedRouteSnapshot,
 state: RouterStateSnapshot
 ): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean|UrlTree { ... }
 }
 
 { path: ..., canDeactivate: [CanDeactivateGuard] }
 | An interface for defining a class that the router should call first to determine if it should deactivate this component after a navigation. Should return a boolean|UrlTree or an Observable/Promise that resolves to a boolean|UrlTree. <p>用来定义类的接口。路由器会在导航离开前首先调用本接口以决定是否取消激活本路由。应该返回一个 <code>boolean|UrlTree</code> 或能解析成 <code>boolean|UrlTree</code> 的 <code>Observable/Promise</code>。</p>
 | 
| class CanActivateChildGuard implements CanActivateChild {canActivateChild(
 route: ActivatedRouteSnapshot,
 state: RouterStateSnapshot
 ): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean|UrlTree { ... }
 }
 
 { path: ..., canActivateChild: [CanActivateGuard],
 children: ... }
 | An interface for defining a class that the router should call first to determine if it should activate the child route. Should return a boolean|UrlTree or an Observable/Promise that resolves to a boolean|UrlTree. 用来定义类的接口。路由器会首先调用本接口来决定是否激活一个子路由。应该返回一个 boolean|UrlTree或能解析成boolean|UrlTree的Observable/Promise。 | 
| <code>class <b>Resolve</b>Guard implements <b>Resolve</b><T> {<br>    resolve(<br>      route: ActivatedRouteSnapshot,<br>      state: RouterStateSnapshot<br>    ): Observable<any>|Promise<any>|any { ... }<br>}<br><br>{ path: ..., resolve: [<b>Resolve</b>Guard] }</code>
 | <p>An interface for defining a class that the router should call first to resolve route data before rendering the route. Should return a value or an Observable/Promise that resolves to a value.</p>
<p>用来定义类的接口。路由器会在渲染该路由之前,首先调用它来解析路由数据。应该返回一个值或能解析成值的 <code>Observable/Promise</code>。</p>
 | 
| <code>class <b>CanLoad</b>Guard implements <b>CanLoad</b> {<br>    canLoad(<br>      route: Route<br>    ): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean|UrlTree { ... }<br>}<br><br>{ path: ..., canLoad: [<b>CanLoad</b>Guard], loadChildren: ... }</code>
 | <p>An interface for defining a class that the router should call first to check if the lazy loaded module should be loaded. Should return a boolean|UrlTree or an Observable/Promise that resolves to a boolean|UrlTree.</p>
<p>用来定义类的接口。路由器会首先调用它来决定是否应该加载一个惰性加载模块。应该返回一个 <code>boolean|UrlTree</code> 或能解析成 <code>boolean|UrlTree</code> 的 <code>Observable/Promise</code>。</p>
 |