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
[x] |common/NgClass | 3,715 | 1.15
[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/EventEmitter | 3,202 | 0.99
[x] |core/Injectable | 3,177 | 0.99
[x] |forms/FormGroup | 3,096 | 0.96
[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
[ ] |router/RouterLink | 2,929 | 0.91
[ ] |core/ViewChild | 2,870 | 0.89
@ -69,8 +69,8 @@
[x] |core/HostBinding | 732 | 0.23
[x] |core/ContentChild | 719 | 0.22
[x] |core/ViewChildren | 717 | 0.22
[ ] |common/http/HttpResponse | 714 | 0.22
[ ] |router/ActivatedRouteSnapshot | 700 | 0.22
[x] |common/http/HttpResponse | 714 | 0.22
[x] |router/ActivatedRouteSnapshot | 700 | 0.22
[ ] |common/http | 683 | 0.21
[ ] |core/ChangeDetectorRef | 670 | 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
* outlet. An `ActivatedRoute` can also be used to traverse the router state tree.
*
* `ActivatedRoute`
*
* ```
* @Component({...})
* class MyComponent {
@ -105,7 +107,10 @@ export function createEmptyStateSnapshot(
*
*/
export class ActivatedRoute {
/** The current snapshot of this route */
/** The current snapshot of this route
*
*
*/
// TODO(issue/24571): remove '!'.
snapshot !: ActivatedRouteSnapshot;
/** @internal */
@ -122,40 +127,79 @@ export class ActivatedRoute {
/** @internal */
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[]>,
/** 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>,
/** 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>,
/** 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>,
/** 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>,
/** The outlet name of the route. It's a constant */
/** The outlet name of the route. It's a constant
*
*
*/
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
public component: Type<any>|string|null, futureSnapshot: ActivatedRouteSnapshot) {
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; }
/** The root of the router state */
/** The root of the router state
*
*
*/
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); }
/** 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); }
/** 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); }
/** 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 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
* traverse the router state tree.
*
* `ActivatedRoute`
* `ActivatedRouteSnapshot`
*
* ```
* @Component({templateUrl:'./my-component.html'})
* class MyComponent {
@ -252,7 +299,10 @@ function flattenInherited(pathFromRoot: ActivatedRouteSnapshot[]): Inherited {
*
*/
export class ActivatedRouteSnapshot {
/** The configuration used to match this route **/
/** The configuration used to match this route
*
*
**/
public readonly routeConfig: Route|null;
/** @internal **/
_urlSegment: UrlSegmentGroup;
@ -275,19 +325,40 @@ export class ActivatedRouteSnapshot {
/** @internal */
constructor(
/** The URL segments matched by this route */
/** The URL segments matched by this route
*
* URL
*/
public url: UrlSegment[],
/** The matrix parameters scoped to this route */
/** The matrix parameters scoped to this route
*
* `;`
*/
public params: Params,
/** The query parameters shared by all the routes */
/** The query parameters shared by all the routes
*
* `?`
*/
public queryParams: Params,
/** The URL fragment shared by all the routes */
/** The URL fragment shared by all the routes
*
* URL `#`
*/
public fragment: string,
/** The static and resolved data of this route */
/** The static and resolved data of this route
*
*
*/
public data: Data,
/** The outlet name of the route */
/** The outlet name of the route
*
* outlet
*/
public outlet: string,
/** The component of the route */
/** The component of the route
*
*
*/
public component: Type<any>|string|null, routeConfig: Route|null, urlSegment: UrlSegmentGroup,
lastPathIndex: number, resolve: ResolveData) {
this.routeConfig = routeConfig;
@ -296,19 +367,34 @@ export class ActivatedRouteSnapshot {
this._resolve = resolve;
}
/** The root of the router state */
/** The root of the router state
*
*
*/
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); }
/** 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); }
/** 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); }
/** 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 paramMap(): ParamMap {
@ -337,11 +423,17 @@ export class ActivatedRouteSnapshot {
*
* 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
* the "consumed" URL segments, the extracted parameters, and the resolved data.
*
* "已消费的" URL
*
* ### Example
*
* ###
*
* ```
* @Component({templateUrl:'template.html'})
* 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.
* 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.
*
* `Observable`
* snapshot
*/
export function advanceActivatedRoute(route: ActivatedRoute): void {
if (route.snapshot) {