docs(API): 翻译完了 ActivatedRoute

This commit is contained in:
Zhicheng Wang 2018-09-01 09:57:03 +08:00
parent e436d6972b
commit f224ca6265
2 changed files with 126 additions and 31 deletions

View File

@ -14,13 +14,13 @@
[ ] |animations/animate | 3,817 | 1.19 [ ] |animations/animate | 3,817 | 1.19
[x] |common/NgClass | 3,715 | 1.15 [x] |common/NgClass | 3,715 | 1.15
[x] |common/DatePipe | 3,576 | 1.11 [x] |common/DatePipe | 3,576 | 1.11
[ ] |forms/FormsModule | 3,381 | 1.05 [x] |forms/FormsModule | 3,381 | 1.05
[x] |core/Input | 3,354 | 1.04 [x] |core/Input | 3,354 | 1.04
[x] |core/EventEmitter | 3,202 | 0.99 [x] |core/EventEmitter | 3,202 | 0.99
[x] |core/Injectable | 3,177 | 0.99 [x] |core/Injectable | 3,177 | 0.99
[x] |forms/FormGroup | 3,096 | 0.96 [x] |forms/FormGroup | 3,096 | 0.96
[x] |forms/FormControl | 3,034 | 0.94 [x] |forms/FormControl | 3,034 | 0.94
[ ] |router/ActivatedRoute | 2,993 | 0.93 [x] |router/ActivatedRoute | 2,993 | 0.93
[ ] |forms/AbstractControl | 2,930 | 0.91 [ ] |forms/AbstractControl | 2,930 | 0.91
[ ] |router/RouterLink | 2,929 | 0.91 [ ] |router/RouterLink | 2,929 | 0.91
[ ] |core/ViewChild | 2,870 | 0.89 [ ] |core/ViewChild | 2,870 | 0.89
@ -69,8 +69,8 @@
[x] |core/HostBinding | 732 | 0.23 [x] |core/HostBinding | 732 | 0.23
[x] |core/ContentChild | 719 | 0.22 [x] |core/ContentChild | 719 | 0.22
[x] |core/ViewChildren | 717 | 0.22 [x] |core/ViewChildren | 717 | 0.22
[ ] |common/http/HttpResponse | 714 | 0.22 [x] |common/http/HttpResponse | 714 | 0.22
[ ] |router/ActivatedRouteSnapshot | 700 | 0.22 [x] |router/ActivatedRouteSnapshot | 700 | 0.22
[ ] |common/http | 683 | 0.21 [ ] |common/http | 683 | 0.21
[ ] |core/ChangeDetectorRef | 670 | 0.21 [ ] |core/ChangeDetectorRef | 670 | 0.21
[ ] |router/NavigationStart | 663 | 0.21 [ ] |router/NavigationStart | 663 | 0.21

View File

@ -90,6 +90,8 @@ export function createEmptyStateSnapshot(
* Contains the information about a route associated with a component loaded in an * Contains the information about a route associated with a component loaded in an
* outlet. An `ActivatedRoute` can also be used to traverse the router state tree. * outlet. An `ActivatedRoute` can also be used to traverse the router state tree.
* *
* `ActivatedRoute`
*
* ``` * ```
* @Component({...}) * @Component({...})
* class MyComponent { * class MyComponent {
@ -105,7 +107,10 @@ export function createEmptyStateSnapshot(
* *
*/ */
export class ActivatedRoute { export class ActivatedRoute {
/** The current snapshot of this route */ /** The current snapshot of this route
*
*
*/
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
snapshot !: ActivatedRouteSnapshot; snapshot !: ActivatedRouteSnapshot;
/** @internal */ /** @internal */
@ -122,40 +127,79 @@ export class ActivatedRoute {
/** @internal */ /** @internal */
constructor( constructor(
/** An observable of the URL segments matched by this route */ /** An observable of the URL segments matched by this route
*
* `Observable` URL
*/
public url: Observable<UrlSegment[]>, public url: Observable<UrlSegment[]>,
/** An observable of the matrix parameters scoped to this route */ /** An observable of the matrix parameters scoped to this route
*
* `Observable``;`
*/
public params: Observable<Params>, public params: Observable<Params>,
/** An observable of the query parameters shared by all the routes */ /** An observable of the query parameters shared by all the routes
*
* `Observable``?`
*/
public queryParams: Observable<Params>, public queryParams: Observable<Params>,
/** An observable of the URL fragment shared by all the routes */ /** An observable of the URL fragment shared by all the routes
*
* `Observable` URL `#`
*/
public fragment: Observable<string>, public fragment: Observable<string>,
/** An observable of the static and resolved data of this route. */ /** An observable of the static and resolved data of this route.
*
* `Observable`
*/
public data: Observable<Data>, public data: Observable<Data>,
/** The outlet name of the route. It's a constant */ /** The outlet name of the route. It's a constant
*
*
*/
public outlet: string, public outlet: string,
/** The component of the route. It's a constant */ /** The component of the route. It's a constant
*
*
*/
// TODO(vsavkin): remove |string // TODO(vsavkin): remove |string
public component: Type<any>|string|null, futureSnapshot: ActivatedRouteSnapshot) { public component: Type<any>|string|null, futureSnapshot: ActivatedRouteSnapshot) {
this._futureSnapshot = futureSnapshot; this._futureSnapshot = futureSnapshot;
} }
/** The configuration used to match this route */ /** The configuration used to match this route
*
*
*/
get routeConfig(): Route|null { return this._futureSnapshot.routeConfig; } get routeConfig(): Route|null { return this._futureSnapshot.routeConfig; }
/** The root of the router state */ /** The root of the router state
*
*
*/
get root(): ActivatedRoute { return this._routerState.root; } get root(): ActivatedRoute { return this._routerState.root; }
/** The parent of this route in the router state tree */ /** The parent of this route in the router state tree
*
*
*/
get parent(): ActivatedRoute|null { return this._routerState.parent(this); } get parent(): ActivatedRoute|null { return this._routerState.parent(this); }
/** The first child of this route in the router state tree */ /** The first child of this route in the router state tree
*
*
*/
get firstChild(): ActivatedRoute|null { return this._routerState.firstChild(this); } get firstChild(): ActivatedRoute|null { return this._routerState.firstChild(this); }
/** The children of this route in the router state tree */ /** The children of this route in the router state tree
*
*
*/
get children(): ActivatedRoute[] { return this._routerState.children(this); } get children(): ActivatedRoute[] { return this._routerState.children(this); }
/** The path from the root of the router state tree to this route */ /** The path from the root of the router state tree to this route
*
*
*/
get pathFromRoot(): ActivatedRoute[] { return this._routerState.pathFromRoot(this); } get pathFromRoot(): ActivatedRoute[] { return this._routerState.pathFromRoot(this); }
get paramMap(): Observable<ParamMap> { get paramMap(): Observable<ParamMap> {
@ -238,6 +282,9 @@ function flattenInherited(pathFromRoot: ActivatedRouteSnapshot[]): Inherited {
* outlet at a particular moment in time. ActivatedRouteSnapshot can also be used to * outlet at a particular moment in time. ActivatedRouteSnapshot can also be used to
* traverse the router state tree. * traverse the router state tree.
* *
* `ActivatedRoute`
* `ActivatedRouteSnapshot`
*
* ``` * ```
* @Component({templateUrl:'./my-component.html'}) * @Component({templateUrl:'./my-component.html'})
* class MyComponent { * class MyComponent {
@ -252,7 +299,10 @@ function flattenInherited(pathFromRoot: ActivatedRouteSnapshot[]): Inherited {
* *
*/ */
export class ActivatedRouteSnapshot { export class ActivatedRouteSnapshot {
/** The configuration used to match this route **/ /** The configuration used to match this route
*
*
**/
public readonly routeConfig: Route|null; public readonly routeConfig: Route|null;
/** @internal **/ /** @internal **/
_urlSegment: UrlSegmentGroup; _urlSegment: UrlSegmentGroup;
@ -275,19 +325,40 @@ export class ActivatedRouteSnapshot {
/** @internal */ /** @internal */
constructor( constructor(
/** The URL segments matched by this route */ /** The URL segments matched by this route
*
* URL
*/
public url: UrlSegment[], public url: UrlSegment[],
/** The matrix parameters scoped to this route */ /** The matrix parameters scoped to this route
*
* `;`
*/
public params: Params, public params: Params,
/** The query parameters shared by all the routes */ /** The query parameters shared by all the routes
*
* `?`
*/
public queryParams: Params, public queryParams: Params,
/** The URL fragment shared by all the routes */ /** The URL fragment shared by all the routes
*
* URL `#`
*/
public fragment: string, public fragment: string,
/** The static and resolved data of this route */ /** The static and resolved data of this route
*
*
*/
public data: Data, public data: Data,
/** The outlet name of the route */ /** The outlet name of the route
*
* outlet
*/
public outlet: string, public outlet: string,
/** The component of the route */ /** The component of the route
*
*
*/
public component: Type<any>|string|null, routeConfig: Route|null, urlSegment: UrlSegmentGroup, public component: Type<any>|string|null, routeConfig: Route|null, urlSegment: UrlSegmentGroup,
lastPathIndex: number, resolve: ResolveData) { lastPathIndex: number, resolve: ResolveData) {
this.routeConfig = routeConfig; this.routeConfig = routeConfig;
@ -296,19 +367,34 @@ export class ActivatedRouteSnapshot {
this._resolve = resolve; this._resolve = resolve;
} }
/** The root of the router state */ /** The root of the router state
*
*
*/
get root(): ActivatedRouteSnapshot { return this._routerState.root; } get root(): ActivatedRouteSnapshot { return this._routerState.root; }
/** The parent of this route in the router state tree */ /** The parent of this route in the router state tree
*
*
*/
get parent(): ActivatedRouteSnapshot|null { return this._routerState.parent(this); } get parent(): ActivatedRouteSnapshot|null { return this._routerState.parent(this); }
/** The first child of this route in the router state tree */ /** The first child of this route in the router state tree
*
*
*/
get firstChild(): ActivatedRouteSnapshot|null { return this._routerState.firstChild(this); } get firstChild(): ActivatedRouteSnapshot|null { return this._routerState.firstChild(this); }
/** The children of this route in the router state tree */ /** The children of this route in the router state tree
*
*
*/
get children(): ActivatedRouteSnapshot[] { return this._routerState.children(this); } get children(): ActivatedRouteSnapshot[] { return this._routerState.children(this); }
/** The path from the root of the router state tree to this route */ /** The path from the root of the router state tree to this route
*
*
*/
get pathFromRoot(): ActivatedRouteSnapshot[] { return this._routerState.pathFromRoot(this); } get pathFromRoot(): ActivatedRouteSnapshot[] { return this._routerState.pathFromRoot(this); }
get paramMap(): ParamMap { get paramMap(): ParamMap {
@ -337,11 +423,17 @@ export class ActivatedRouteSnapshot {
* *
* Represents the state of the router at a moment in time. * Represents the state of the router at a moment in time.
* *
*
*
* This is a tree of activated route snapshots. Every node in this tree knows about * This is a tree of activated route snapshots. Every node in this tree knows about
* the "consumed" URL segments, the extracted parameters, and the resolved data. * the "consumed" URL segments, the extracted parameters, and the resolved data.
* *
* "已消费的" URL
*
* ### Example * ### Example
* *
* ###
*
* ``` * ```
* @Component({templateUrl:'template.html'}) * @Component({templateUrl:'template.html'})
* class MyComponent { * class MyComponent {
@ -384,6 +476,9 @@ function serializeNode(node: TreeNode<ActivatedRouteSnapshot>): string {
* The expectation is that the activate route is created with the right set of parameters. * The expectation is that the activate route is created with the right set of parameters.
* So we push new values into the observables only when they are not the initial values. * So we push new values into the observables only when they are not the initial values.
* And we detect that by checking if the snapshot field is set. * And we detect that by checking if the snapshot field is set.
*
* `Observable`
* snapshot
*/ */
export function advanceActivatedRoute(route: ActivatedRoute): void { export function advanceActivatedRoute(route: ActivatedRoute): void {
if (route.snapshot) { if (route.snapshot) {