docs(API): 翻译完了大部分路由器事件

This commit is contained in:
Zhicheng Wang 2018-09-04 14:36:08 +08:00
parent 0d7988992b
commit a033f25b13
2 changed files with 57 additions and 1 deletions

View File

@ -58,7 +58,7 @@
[x] | common/http/HttpInterceptor | 0.30
[x] | common/http/HttpRequest | 0.29
[x] | router/CanActivate | 0.27
[ ] | router | 0.26
[x] | router | 0.26
[ ] | animations/style | 0.25
[ ] | common/SlicePipe | 0.25
[ ] | router/Event | 0.25

View File

@ -14,10 +14,20 @@ import {ActivatedRouteSnapshot, RouterStateSnapshot} from './router_state';
*
* Identifies the trigger of the navigation.
*
*
*
* * 'imperative'--triggered by `router.navigateByUrl` or `router.navigate`.
*
* 'imperative' `router.navigateByUrl` `router.navigate`
*
* * 'popstate'--triggered by a popstate event
*
* 'popstate' popstate
*
* * 'hashchange'--triggered by a hashchange event
*
* 'hashchange' hashchange
*
* @experimental
*/
export type NavigationTrigger = 'imperative' | 'popstate' | 'hashchange';
@ -28,8 +38,12 @@ export type NavigationTrigger = 'imperative' | 'popstate' | 'hashchange';
* Base for events the Router goes through, as opposed to events tied to a specific
* Route. `RouterEvent`s will only be fired one time for any given navigation.
*
* `RouterEvent`
*
* Example:
*
*
*
* ```
* class MyService {
* constructor(public router: Router, logger: Logger) {
@ -55,15 +69,27 @@ export class RouterEvent {
*
* Represents an event triggered when a navigation starts.
*
*
*
*/
export class NavigationStart extends RouterEvent {
/**
* Identifies the trigger of the navigation.
*
*
*
* * 'imperative'--triggered by `router.navigateByUrl` or `router.navigate`.
*
* 'imperative' `router.navigateByUrl` `router.navigate`
*
* * 'popstate'--triggered by a popstate event
*
* 'popstate' popstate
*
* * 'hashchange'--triggered by a hashchange event
*
* 'hashchange' hashchange
*
*/
navigationTrigger?: 'imperative'|'popstate'|'hashchange';
@ -71,6 +97,8 @@ export class NavigationStart extends RouterEvent {
* This contains the navigation id that pushed the history record that the router navigates
* back to. This is not null only when the navigation is triggered by a popstate event.
*
* `navigationId` popstate
*
* The router assigns a navigationId to every router transition/navigation. Even when the user
* clicks on the back button in the browser, a new navigation id will be created. So from
* the perspective of the router, the router never "goes back". By using the `restoredState`
@ -78,6 +106,10 @@ export class NavigationStart extends RouterEvent {
* states
* and popstate events. In the latter case you can restore some remembered state (e.g., scroll
* position).
*
* `navigationId` /使退 `navigationId`
* "后退" `restoredState` navigationId `popstate`
* `popstate`
*/
restoredState?: {navigationId: number}|null;
@ -104,6 +136,7 @@ export class NavigationStart extends RouterEvent {
*
* Represents an event triggered when a navigation ends successfully.
*
*
*
*/
export class NavigationEnd extends RouterEvent {
@ -128,6 +161,7 @@ export class NavigationEnd extends RouterEvent {
*
* Represents an event triggered when a navigation is canceled.
*
*
*
*/
export class NavigationCancel extends RouterEvent {
@ -150,6 +184,7 @@ export class NavigationCancel extends RouterEvent {
*
* Represents an event triggered when a navigation fails due to an unexpected error.
*
*
*
*/
export class NavigationError extends RouterEvent {
@ -174,6 +209,7 @@ export class NavigationError extends RouterEvent {
*
* Represents an event triggered when routes are recognized.
*
*
*
*/
export class RoutesRecognized extends RouterEvent {
@ -200,6 +236,8 @@ export class RoutesRecognized extends RouterEvent {
*
* Represents the start of the Guard phase of routing.
*
* `Guard`
*
* @experimental
*/
export class GuardsCheckStart extends RouterEvent {
@ -225,6 +263,8 @@ export class GuardsCheckStart extends RouterEvent {
*
* Represents the end of the Guard phase of routing.
*
* `Guard`
*
* @experimental
*/
export class GuardsCheckEnd extends RouterEvent {
@ -255,6 +295,10 @@ export class GuardsCheckEnd extends RouterEvent {
* in the "resolve" phase whether there's things to resolve or not. In the future this
* behavior may change to only run when there are things to be resolved.
*
* `Resolve`
* `resolve` 西 `resolve`
* 西 `resolve`
*
* @experimental
*/
export class ResolveStart extends RouterEvent {
@ -281,6 +325,8 @@ export class ResolveStart extends RouterEvent {
* Represents the end of the Resolve phase of routing. See note on
* `ResolveStart` for use of this experimental API.
*
* `Resolve` `ResolveStart` API
*
* @experimental
*/
export class ResolveEnd extends RouterEvent {
@ -306,6 +352,8 @@ export class ResolveEnd extends RouterEvent {
*
* Represents an event triggered before lazy loading a route config.
*
*
*
* @experimental
*/
export class RouteConfigLoadStart {
@ -320,6 +368,8 @@ export class RouteConfigLoadStart {
*
* Represents an event triggered when a route has been lazy loaded.
*
*
*
* @experimental
*/
export class RouteConfigLoadEnd {
@ -405,6 +455,8 @@ export class ActivationEnd {
* @description
*
* Represents a scrolling event.
*
*
*/
export class Scroll {
constructor(
@ -428,8 +480,12 @@ export class Scroll {
*
* Represents a router event, allowing you to track the lifecycle of the router.
*
*
*
* The sequence of router events is:
*
*
*
* - `NavigationStart`,
* - `RouteConfigLoadStart`,
* - `RouteConfigLoadEnd`,