2017-02-01 16:13:57 -05:00
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2017-02-01 16:13:57 -05:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {Route} from './config';
|
2017-09-04 16:00:59 -04:00
|
|
|
import {ActivatedRouteSnapshot, RouterStateSnapshot} from './router_state';
|
|
|
|
|
2018-01-24 12:19:59 -05:00
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* Identifies the call or event that triggered a navigation.
|
2018-04-05 06:51:21 -04:00
|
|
|
*
|
2019-07-03 19:15:15 -04:00
|
|
|
* * 'imperative': Triggered by `router.navigateByUrl()` or `router.navigate()`.
|
|
|
|
* * 'popstate' : Triggered by a `popstate` event.
|
|
|
|
* * 'hashchange'-: Triggered by a `hashchange` event.
|
2018-01-24 12:19:59 -05:00
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2018-01-24 12:19:59 -05:00
|
|
|
*/
|
2020-04-13 19:40:21 -04:00
|
|
|
export type NavigationTrigger = 'imperative'|'popstate'|'hashchange';
|
2017-02-01 16:13:57 -05:00
|
|
|
|
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* Base for events the router goes through, as opposed to events tied to a specific
|
|
|
|
* route. Fired one time for any given navigation.
|
2017-02-01 16:13:57 -05:00
|
|
|
*
|
2020-06-01 17:58:07 -04:00
|
|
|
* The following code shows how a class subscribes to router events.
|
2017-07-25 14:13:15 -04:00
|
|
|
*
|
2019-07-03 19:15:15 -04:00
|
|
|
* ```ts
|
2017-07-25 14:13:15 -04:00
|
|
|
* class MyService {
|
|
|
|
* constructor(public router: Router, logger: Logger) {
|
2018-08-27 10:09:31 -04:00
|
|
|
* router.events.pipe(
|
2020-05-12 15:29:11 -04:00
|
|
|
* filter((e: Event): e is RouterEvent => e instanceof RouterEvent)
|
|
|
|
* ).subscribe((e: RouterEvent) => {
|
2017-07-25 14:13:15 -04:00
|
|
|
* logger.log(e.id, e.url);
|
|
|
|
* });
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*
|
2019-07-03 19:15:15 -04:00
|
|
|
* @see `Event`
|
2020-06-01 17:58:07 -04:00
|
|
|
* @see [Router events summary](guide/router#router-events)
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-02-01 16:13:57 -05:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class RouterEvent {
|
2017-02-01 16:13:57 -05:00
|
|
|
constructor(
|
2019-07-03 19:15:15 -04:00
|
|
|
/** A unique ID that the router assigns to every router navigation. */
|
2017-02-01 16:13:57 -05:00
|
|
|
public id: number,
|
2019-07-03 19:15:15 -04:00
|
|
|
/** The URL that is the destination for this navigation. */
|
2017-02-01 16:13:57 -05:00
|
|
|
public url: string) {}
|
2017-07-25 14:13:15 -04:00
|
|
|
}
|
2017-02-01 16:13:57 -05:00
|
|
|
|
2017-07-25 14:13:15 -04:00
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* An event triggered when a navigation starts.
|
2017-07-25 14:13:15 -04:00
|
|
|
*
|
2018-10-19 13:25:11 -04:00
|
|
|
* @publicApi
|
2017-07-25 14:13:15 -04:00
|
|
|
*/
|
|
|
|
export class NavigationStart extends RouterEvent {
|
2018-01-24 12:19:59 -05:00
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* Identifies the call or event that triggered the navigation.
|
|
|
|
* An `imperative` trigger is a call to `router.navigateByUrl()` or `router.navigate()`.
|
2018-01-24 12:19:59 -05:00
|
|
|
*
|
2020-06-01 17:58:07 -04:00
|
|
|
* @see `NavigationEnd`
|
|
|
|
* @see `NavigationCancel`
|
|
|
|
* @see `NavigationError`
|
2018-01-24 12:19:59 -05:00
|
|
|
*/
|
|
|
|
navigationTrigger?: 'imperative'|'popstate'|'hashchange';
|
|
|
|
|
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* The navigation state that was previously supplied to the `pushState` call,
|
|
|
|
* when the navigation is triggered by a `popstate` event. Otherwise null.
|
2018-01-24 12:19:59 -05:00
|
|
|
*
|
2019-07-03 19:15:15 -04:00
|
|
|
* The state object is defined by `NavigationExtras`, and contains any
|
|
|
|
* developer-defined state value, as well as a unique ID that
|
|
|
|
* the router assigns to every router transition/navigation.
|
|
|
|
*
|
|
|
|
* From the perspective of the router, the router never "goes back".
|
|
|
|
* When the user clicks on the back button in the browser,
|
|
|
|
* a new navigation ID is created.
|
|
|
|
*
|
|
|
|
* Use the ID in this previous-state object to differentiate between a newly created
|
|
|
|
* state and one returned to by a `popstate` event, so that you can restore some
|
|
|
|
* remembered state, such as scroll position.
|
2018-11-29 13:07:24 -05:00
|
|
|
*
|
2018-01-24 12:19:59 -05:00
|
|
|
*/
|
2018-11-29 13:07:24 -05:00
|
|
|
restoredState?: {[k: string]: any, navigationId: number}|null;
|
2018-01-24 12:19:59 -05:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
|
|
|
id: number,
|
|
|
|
/** @docsNotRequired */
|
|
|
|
url: string,
|
|
|
|
/** @docsNotRequired */
|
|
|
|
navigationTrigger: 'imperative'|'popstate'|'hashchange' = 'imperative',
|
|
|
|
/** @docsNotRequired */
|
2018-11-29 13:07:24 -05:00
|
|
|
restoredState: {[k: string]: any, navigationId: number}|null = null) {
|
2018-01-24 12:19:59 -05:00
|
|
|
super(id, url);
|
|
|
|
this.navigationTrigger = navigationTrigger;
|
|
|
|
this.restoredState = restoredState;
|
|
|
|
}
|
|
|
|
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
2020-04-13 19:40:21 -04:00
|
|
|
toString(): string {
|
|
|
|
return `NavigationStart(id: ${this.id}, url: '${this.url}')`;
|
|
|
|
}
|
2017-02-01 16:13:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* An event triggered when a navigation ends successfully.
|
2017-02-01 16:13:57 -05:00
|
|
|
*
|
2020-06-01 17:58:07 -04:00
|
|
|
* @see `NavigationStart`
|
|
|
|
* @see `NavigationCancel`
|
|
|
|
* @see `NavigationError`
|
|
|
|
*
|
2018-10-19 13:25:11 -04:00
|
|
|
* @publicApi
|
2017-02-01 16:13:57 -05:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class NavigationEnd extends RouterEvent {
|
2017-02-01 16:13:57 -05:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public urlAfterRedirects: string) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-02-01 16:13:57 -05:00
|
|
|
|
|
|
|
/** @docsNotRequired */
|
|
|
|
toString(): string {
|
2020-04-13 19:40:21 -04:00
|
|
|
return `NavigationEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${
|
|
|
|
this.urlAfterRedirects}')`;
|
2017-02-01 16:13:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-08-14 14:04:26 -04:00
|
|
|
* An event triggered when a navigation is canceled, directly or indirectly.
|
2020-06-01 17:58:07 -04:00
|
|
|
* This can happen when a route guard
|
2019-08-14 14:04:26 -04:00
|
|
|
* returns `false` or initiates a redirect by returning a `UrlTree`.
|
2017-02-01 16:13:57 -05:00
|
|
|
*
|
2020-06-01 17:58:07 -04:00
|
|
|
* @see `NavigationStart`
|
|
|
|
* @see `NavigationEnd`
|
|
|
|
* @see `NavigationError`
|
|
|
|
*
|
2018-10-19 13:25:11 -04:00
|
|
|
* @publicApi
|
2017-02-01 16:13:57 -05:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class NavigationCancel extends RouterEvent {
|
2017-02-01 16:13:57 -05:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public reason: string) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-02-01 16:13:57 -05:00
|
|
|
|
|
|
|
/** @docsNotRequired */
|
2020-04-13 19:40:21 -04:00
|
|
|
toString(): string {
|
|
|
|
return `NavigationCancel(id: ${this.id}, url: '${this.url}')`;
|
|
|
|
}
|
2017-02-01 16:13:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* An event triggered when a navigation fails due to an unexpected error.
|
2017-02-01 16:13:57 -05:00
|
|
|
*
|
2020-06-01 17:58:07 -04:00
|
|
|
* @see `NavigationStart`
|
|
|
|
* @see `NavigationEnd`
|
|
|
|
* @see `NavigationCancel`
|
|
|
|
*
|
2018-10-19 13:25:11 -04:00
|
|
|
* @publicApi
|
2017-02-01 16:13:57 -05:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class NavigationError extends RouterEvent {
|
2017-02-01 16:13:57 -05:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public error: any) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-02-01 16:13:57 -05:00
|
|
|
|
|
|
|
/** @docsNotRequired */
|
|
|
|
toString(): string {
|
|
|
|
return `NavigationError(id: ${this.id}, url: '${this.url}', error: ${this.error})`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-06-01 17:58:07 -04:00
|
|
|
* An event triggered when routes are recognized.
|
2017-02-01 16:13:57 -05:00
|
|
|
*
|
2018-10-19 13:25:11 -04:00
|
|
|
* @publicApi
|
2017-02-01 16:13:57 -05:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class RoutesRecognized extends RouterEvent {
|
2017-02-01 16:13:57 -05:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
|
|
|
public urlAfterRedirects: string,
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public state: RouterStateSnapshot) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-02-01 16:13:57 -05:00
|
|
|
|
|
|
|
/** @docsNotRequired */
|
|
|
|
toString(): string {
|
2020-04-13 19:40:21 -04:00
|
|
|
return `RoutesRecognized(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${
|
|
|
|
this.urlAfterRedirects}', state: ${this.state})`;
|
2017-02-01 16:13:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* An event triggered at the start of the Guard phase of routing.
|
2017-07-01 13:30:17 -04:00
|
|
|
*
|
2020-06-01 17:58:07 -04:00
|
|
|
* @see `GuardsCheckEnd`
|
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-01 13:30:17 -04:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class GuardsCheckStart extends RouterEvent {
|
2017-07-01 13:30:17 -04:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
|
|
|
public urlAfterRedirects: string,
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public state: RouterStateSnapshot) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-07-01 13:30:17 -04:00
|
|
|
|
|
|
|
toString(): string {
|
2020-04-13 19:40:21 -04:00
|
|
|
return `GuardsCheckStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${
|
|
|
|
this.urlAfterRedirects}', state: ${this.state})`;
|
2017-07-01 13:30:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* An event triggered at the end of the Guard phase of routing.
|
2017-07-01 13:30:17 -04:00
|
|
|
*
|
2020-06-01 17:58:07 -04:00
|
|
|
* @see `GuardsCheckStart`
|
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-01 13:30:17 -04:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class GuardsCheckEnd extends RouterEvent {
|
2017-07-01 13:30:17 -04:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
|
|
|
public urlAfterRedirects: string,
|
|
|
|
/** @docsNotRequired */
|
|
|
|
public state: RouterStateSnapshot,
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public shouldActivate: boolean) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-07-01 13:30:17 -04:00
|
|
|
|
|
|
|
toString(): string {
|
2020-04-13 19:40:21 -04:00
|
|
|
return `GuardsCheckEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${
|
|
|
|
this.urlAfterRedirects}', state: ${this.state}, shouldActivate: ${this.shouldActivate})`;
|
2017-07-01 13:30:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* An event triggered at the the start of the Resolve phase of routing.
|
2018-04-05 06:51:21 -04:00
|
|
|
*
|
2019-07-03 19:15:15 -04:00
|
|
|
* Runs in the "resolve" phase whether or not there is anything to resolve.
|
|
|
|
* In future, may change to only run when there are things to be resolved.
|
2017-07-01 13:30:17 -04:00
|
|
|
*
|
2020-06-01 17:58:07 -04:00
|
|
|
* @see `ResolveEnd`
|
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-01 13:30:17 -04:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class ResolveStart extends RouterEvent {
|
2017-07-01 13:30:17 -04:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
|
|
|
public urlAfterRedirects: string,
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public state: RouterStateSnapshot) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-07-01 13:30:17 -04:00
|
|
|
|
|
|
|
toString(): string {
|
2020-04-13 19:40:21 -04:00
|
|
|
return `ResolveStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${
|
|
|
|
this.urlAfterRedirects}', state: ${this.state})`;
|
2017-07-01 13:30:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* An event triggered at the end of the Resolve phase of routing.
|
|
|
|
* @see `ResolveStart`.
|
2017-07-01 13:30:17 -04:00
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-01 13:30:17 -04:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class ResolveEnd extends RouterEvent {
|
2017-07-01 13:30:17 -04:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
|
|
|
public urlAfterRedirects: string,
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public state: RouterStateSnapshot) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-07-01 13:30:17 -04:00
|
|
|
|
|
|
|
toString(): string {
|
2020-04-13 19:40:21 -04:00
|
|
|
return `ResolveEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${
|
|
|
|
this.urlAfterRedirects}', state: ${this.state})`;
|
2017-07-01 13:30:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-25 14:13:15 -04:00
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* An event triggered before lazy loading a route configuration.
|
2017-07-25 14:13:15 -04:00
|
|
|
*
|
2020-06-01 17:58:07 -04:00
|
|
|
* @see `RouteConfigLoadEnd`
|
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-25 14:13:15 -04:00
|
|
|
*/
|
2017-09-05 14:54:33 -04:00
|
|
|
export class RouteConfigLoadStart {
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
|
|
|
public route: Route) {}
|
2020-04-13 19:40:21 -04:00
|
|
|
toString(): string {
|
|
|
|
return `RouteConfigLoadStart(path: ${this.route.path})`;
|
|
|
|
}
|
2017-07-25 14:13:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* An event triggered when a route has been lazy loaded.
|
2017-07-25 14:13:15 -04:00
|
|
|
*
|
2020-06-01 17:58:07 -04:00
|
|
|
* @see `RouteConfigLoadStart`
|
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-25 14:13:15 -04:00
|
|
|
*/
|
2017-09-05 14:54:33 -04:00
|
|
|
export class RouteConfigLoadEnd {
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
|
|
|
public route: Route) {}
|
2020-04-13 19:40:21 -04:00
|
|
|
toString(): string {
|
|
|
|
return `RouteConfigLoadEnd(path: ${this.route.path})`;
|
|
|
|
}
|
2017-07-25 14:13:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* An event triggered at the start of the child-activation
|
|
|
|
* part of the Resolve phase of routing.
|
|
|
|
* @see `ChildActivationEnd`
|
|
|
|
* @see `ResolveStart`
|
2017-07-25 14:13:15 -04:00
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-25 14:13:15 -04:00
|
|
|
*/
|
2017-09-05 14:54:33 -04:00
|
|
|
export class ChildActivationStart {
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-09-04 16:00:59 -04:00
|
|
|
public snapshot: ActivatedRouteSnapshot) {}
|
|
|
|
toString(): string {
|
|
|
|
const path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
|
|
|
|
return `ChildActivationStart(path: '${path}')`;
|
|
|
|
}
|
2017-07-25 14:13:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* An event triggered at the end of the child-activation part
|
|
|
|
* of the Resolve phase of routing.
|
|
|
|
* @see `ChildActivationStart`
|
2020-06-01 17:58:07 -04:00
|
|
|
* @see `ResolveStart`
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-25 14:13:15 -04:00
|
|
|
*/
|
2017-09-05 14:54:33 -04:00
|
|
|
export class ChildActivationEnd {
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-09-04 16:00:59 -04:00
|
|
|
public snapshot: ActivatedRouteSnapshot) {}
|
|
|
|
toString(): string {
|
|
|
|
const path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
|
|
|
|
return `ChildActivationEnd(path: '${path}')`;
|
|
|
|
}
|
2017-07-25 14:13:15 -04:00
|
|
|
}
|
|
|
|
|
2017-09-06 14:00:32 -04:00
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* An event triggered at the start of the activation part
|
|
|
|
* of the Resolve phase of routing.
|
2020-06-01 17:58:07 -04:00
|
|
|
* @see `ActivationEnd`
|
2019-07-03 19:15:15 -04:00
|
|
|
* @see `ResolveStart`
|
2017-09-06 14:00:32 -04:00
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-09-06 14:00:32 -04:00
|
|
|
*/
|
|
|
|
export class ActivationStart {
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
|
|
|
public snapshot: ActivatedRouteSnapshot) {}
|
|
|
|
toString(): string {
|
|
|
|
const path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
|
2017-09-11 14:27:33 -04:00
|
|
|
return `ActivationStart(path: '${path}')`;
|
2017-09-06 14:00:32 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* An event triggered at the end of the activation part
|
|
|
|
* of the Resolve phase of routing.
|
|
|
|
* @see `ActivationStart`
|
|
|
|
* @see `ResolveStart`
|
2017-09-06 14:00:32 -04:00
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-09-06 14:00:32 -04:00
|
|
|
*/
|
|
|
|
export class ActivationEnd {
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
|
|
|
public snapshot: ActivatedRouteSnapshot) {}
|
|
|
|
toString(): string {
|
|
|
|
const path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
|
2017-09-11 14:27:33 -04:00
|
|
|
return `ActivationEnd(path: '${path}')`;
|
2017-09-06 14:00:32 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-17 07:33:50 -04:00
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* An event triggered by scrolling.
|
2018-10-19 13:25:11 -04:00
|
|
|
*
|
|
|
|
* @publicApi
|
2018-05-17 07:33:50 -04:00
|
|
|
*/
|
|
|
|
export class Scroll {
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
|
|
|
readonly routerEvent: NavigationEnd,
|
|
|
|
|
|
|
|
/** @docsNotRequired */
|
|
|
|
readonly position: [number, number]|null,
|
|
|
|
|
|
|
|
/** @docsNotRequired */
|
|
|
|
readonly anchor: string|null) {}
|
|
|
|
|
|
|
|
toString(): string {
|
|
|
|
const pos = this.position ? `${this.position[0]}, ${this.position[1]}` : null;
|
|
|
|
return `Scroll(anchor: '${this.anchor}', position: '${pos}')`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-01 13:30:17 -04:00
|
|
|
/**
|
2019-07-03 19:15:15 -04:00
|
|
|
* Router events that allow you to track the lifecycle of the router.
|
2017-07-01 13:30:17 -04:00
|
|
|
*
|
2020-06-01 17:58:07 -04:00
|
|
|
* The events occur in the following sequence:
|
|
|
|
*
|
|
|
|
* * [NavigationStart](api/router/NavigationStart): Navigation starts.
|
|
|
|
* * [RouteConfigLoadStart](api/router/RouteConfigLoadStart): Before
|
|
|
|
* the router [lazy loads](/guide/router#lazy-loading) a route configuration.
|
|
|
|
* * [RouteConfigLoadEnd](api/router/RouteConfigLoadEnd): After a route has been lazy loaded.
|
|
|
|
* * [RoutesRecognized](api/router/RoutesRecognized): When the router parses the URL
|
|
|
|
* and the routes are recognized.
|
|
|
|
* * [GuardsCheckStart](api/router/GuardsCheckStart): When the router begins the *guards*
|
|
|
|
* phase of routing.
|
|
|
|
* * [ChildActivationStart](api/router/ChildActivationStart): When the router
|
|
|
|
* begins activating a route's children.
|
|
|
|
* * [ActivationStart](api/router/ActivationStart): When the router begins activating a route.
|
|
|
|
* * [GuardsCheckEnd](api/router/GuardsCheckEnd): When the router finishes the *guards*
|
|
|
|
* phase of routing successfully.
|
|
|
|
* * [ResolveStart](api/router/ResolveStart): When the router begins the *resolve*
|
|
|
|
* phase of routing.
|
|
|
|
* * [ResolveEnd](api/router/ResolveEnd): When the router finishes the *resolve*
|
|
|
|
* phase of routing successfuly.
|
|
|
|
* * [ChildActivationEnd](api/router/ChildActivationEnd): When the router finishes
|
|
|
|
* activating a route's children.
|
|
|
|
* * [ActivationEnd](api/router/ActivationStart): When the router finishes activating a route.
|
|
|
|
* * [NavigationEnd](api/router/NavigationEnd): When navigation ends successfully.
|
|
|
|
* * [NavigationCancel](api/router/NavigationCancel): When navigation is canceled.
|
|
|
|
* * [NavigationError](api/router/NavigationError): When navigation fails
|
|
|
|
* due to an unexpected error.
|
|
|
|
* * [Scroll](api/router/Scroll): When the user scrolls.
|
2017-02-01 16:13:57 -05:00
|
|
|
*
|
2018-10-19 13:25:11 -04:00
|
|
|
* @publicApi
|
2017-02-01 16:13:57 -05:00
|
|
|
*/
|
2020-04-13 19:40:21 -04:00
|
|
|
export type Event = RouterEvent|RouteConfigLoadStart|RouteConfigLoadEnd|ChildActivationStart|
|
|
|
|
ChildActivationEnd|ActivationStart|ActivationEnd|Scroll;
|