/** * @license Angular v10.0.5 * (c) 2010-2020 Google LLC. https://angular.io/ * License: MIT */ import { AfterContentInit } from '@angular/core'; import { ChangeDetectorRef } from '@angular/core'; import { Compiler } from '@angular/core'; import { ComponentFactoryResolver } from '@angular/core'; import { ComponentRef } from '@angular/core'; import { ElementRef } from '@angular/core'; import { EventEmitter } from '@angular/core'; import { HashLocationStrategy } from '@angular/common'; import { InjectionToken } from '@angular/core'; import { Injector } from '@angular/core'; import { Location } from '@angular/common'; import { LocationStrategy } from '@angular/common'; import { ModuleWithProviders } from '@angular/core'; import { NgModuleFactory } from '@angular/core'; import { NgModuleFactoryLoader } from '@angular/core'; import { NgProbeToken } from '@angular/core'; import { Observable } from 'rxjs'; import { OnChanges } from '@angular/core'; import { OnDestroy } from '@angular/core'; import { OnInit } from '@angular/core'; import { PathLocationStrategy } from '@angular/common'; import { PlatformLocation } from '@angular/common'; import { Provider } from '@angular/core'; import { QueryList } from '@angular/core'; import { Renderer2 } from '@angular/core'; import { SimpleChanges } from '@angular/core'; import { Type } from '@angular/core'; import { Version } from '@angular/core'; import { ViewContainerRef } from '@angular/core'; import { ViewportScroller } from '@angular/common'; /** * Provides access to information about a route associated with a component * that is loaded in an outlet. * Use to traverse the `RouterState` tree and extract information from nodes. * * The following example shows how to construct a component using information from a * currently activated route. * * {@example router/activated-route/module.ts region="activated-route" * header="activated-route.component.ts"} * * @see [Getting route information](guide/router#getting-route-information) * * @publicApi */ export declare class ActivatedRoute { /** An observable of the URL segments matched by this route. */ url: Observable; /** An observable of the matrix parameters scoped to this route. */ params: Observable; /** An observable of the query parameters shared by all the routes. */ queryParams: Observable; /** An observable of the URL fragment shared by all the routes. */ fragment: Observable; /** An observable of the static and resolved data of this route. */ data: Observable; /** The outlet name of the route, a constant. */ outlet: string; /** The component of the route, a constant. */ component: Type | string | null; /** The current snapshot of this route */ snapshot: ActivatedRouteSnapshot; /** The configuration used to match this route. */ get routeConfig(): Route | null; /** The root of the router state. */ get root(): ActivatedRoute; /** The parent of this route in the router state tree. */ get parent(): ActivatedRoute | null; /** The first child of this route in the router state tree. */ get firstChild(): ActivatedRoute | null; /** The children of this route in the router state tree. */ get children(): ActivatedRoute[]; /** The path from the root of the router state tree to this route. */ get pathFromRoot(): ActivatedRoute[]; /** * An Observable that contains a map of the required and optional parameters * specific to the route. * The map supports retrieving single and multiple values from the same parameter. */ get paramMap(): Observable; /** * An Observable that contains a map of the query parameters available to all routes. * The map supports retrieving single and multiple values from the query parameter. */ get queryParamMap(): Observable; toString(): string; } /** * @description * * Contains the information about a route associated with a component loaded in an * outlet at a particular moment in time. ActivatedRouteSnapshot can also be used to * traverse the router state tree. * * The following example initializes a component with route information extracted * from the snapshot of the root node at the time of creation. * * ``` * @Component({templateUrl:'./my-component.html'}) * class MyComponent { * constructor(route: ActivatedRoute) { * const id: string = route.snapshot.params.id; * const url: string = route.snapshot.url.join(''); * const user = route.snapshot.data.user; * } * } * ``` * * @publicApi */ export declare class ActivatedRouteSnapshot { /** The URL segments matched by this route */ url: UrlSegment[]; /** The matrix parameters scoped to this route */ params: Params; /** The query parameters shared by all the routes */ queryParams: Params; /** The URL fragment shared by all the routes */ fragment: string; /** The static and resolved data of this route */ data: Data; /** The outlet name of the route */ outlet: string; /** The component of the route */ component: Type | string | null; /** The configuration used to match this route **/ readonly routeConfig: Route | null; /** The root of the router state */ get root(): ActivatedRouteSnapshot; /** The parent of this route in the router state tree */ get parent(): ActivatedRouteSnapshot | null; /** The first child of this route in the router state tree */ get firstChild(): ActivatedRouteSnapshot | null; /** The children of this route in the router state tree */ get children(): ActivatedRouteSnapshot[]; /** The path from the root of the router state tree to this route */ get pathFromRoot(): ActivatedRouteSnapshot[]; get paramMap(): ParamMap; get queryParamMap(): ParamMap; toString(): string; } /** * An event triggered at the end of the activation part * of the Resolve phase of routing. * @see `ActivationStart` * @see `ResolveStart` * * @publicApi */ export declare class ActivationEnd { /** @docsNotRequired */ snapshot: ActivatedRouteSnapshot; constructor( /** @docsNotRequired */ snapshot: ActivatedRouteSnapshot); toString(): string; } /** * An event triggered at the start of the activation part * of the Resolve phase of routing. * @see `ActivationEnd` * @see `ResolveStart` * * @publicApi */ export declare class ActivationStart { /** @docsNotRequired */ snapshot: ActivatedRouteSnapshot; constructor( /** @docsNotRequired */ snapshot: ActivatedRouteSnapshot); toString(): string; } /** * @description * * Interface that a class can implement to be a guard deciding if a route can be activated. * If all guards return `true`, navigation continues. If any guard returns `false`, * navigation is cancelled. If any guard returns a `UrlTree`, the current navigation * is cancelled and a new navigation begins to the `UrlTree` returned from the guard. * * The following example implements a `CanActivate` function that checks whether the * current user has permission to activate the requested route. * * ``` * class UserToken {} * class Permissions { * canActivate(user: UserToken, id: string): boolean { * return true; * } * } * * @Injectable() * class CanActivateTeam implements CanActivate { * constructor(private permissions: Permissions, private currentUser: UserToken) {} * * canActivate( * route: ActivatedRouteSnapshot, * state: RouterStateSnapshot * ): Observable|Promise|boolean|UrlTree { * return this.permissions.canActivate(this.currentUser, route.params.id); * } * } * ``` * * Here, the defined guard function is provided as part of the `Route` object * in the router configuration: * * ``` * @NgModule({ * imports: [ * RouterModule.forRoot([ * { * path: 'team/:id', * component: TeamComponent, * canActivate: [CanActivateTeam] * } * ]) * ], * providers: [CanActivateTeam, UserToken, Permissions] * }) * class AppModule {} * ``` * * You can alternatively provide an in-line function with the `canActivate` signature: * * ``` * @NgModule({ * imports: [ * RouterModule.forRoot([ * { * path: 'team/:id', * component: TeamComponent, * canActivate: ['canActivateTeam'] * } * ]) * ], * providers: [ * { * provide: 'canActivateTeam', * useValue: (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => true * } * ] * }) * class AppModule {} * ``` * * @publicApi */ export declare interface CanActivate { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree; } /** * @description * * Interface that a class can implement to be a guard deciding if a child route can be activated. * If all guards return `true`, navigation continues. If any guard returns `false`, * navigation is cancelled. If any guard returns a `UrlTree`, current navigation * is cancelled and a new navigation begins to the `UrlTree` returned from the guard. * * The following example implements a `CanActivateChild` function that checks whether the * current user has permission to activate the requested child route. * * ``` * class UserToken {} * class Permissions { * canActivate(user: UserToken, id: string): boolean { * return true; * } * } * * @Injectable() * class CanActivateTeam implements CanActivateChild { * constructor(private permissions: Permissions, private currentUser: UserToken) {} * * canActivateChild( * route: ActivatedRouteSnapshot, * state: RouterStateSnapshot * ): Observable|Promise|boolean|UrlTree { * return this.permissions.canActivate(this.currentUser, route.params.id); * } * } * ``` * * Here, the defined guard function is provided as part of the `Route` object * in the router configuration: * * ``` * @NgModule({ * imports: [ * RouterModule.forRoot([ * { * path: 'root', * canActivateChild: [CanActivateTeam], * children: [ * { * path: 'team/:id', * component: TeamComponent * } * ] * } * ]) * ], * providers: [CanActivateTeam, UserToken, Permissions] * }) * class AppModule {} * ``` * * You can alternatively provide an in-line function with the `canActivateChild` signature: * * ``` * @NgModule({ * imports: [ * RouterModule.forRoot([ * { * path: 'root', * canActivateChild: ['canActivateTeam'], * children: [ * { * path: 'team/:id', * component: TeamComponent * } * ] * } * ]) * ], * providers: [ * { * provide: 'canActivateTeam', * useValue: (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => true * } * ] * }) * class AppModule {} * ``` * * @publicApi */ export declare interface CanActivateChild { canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree; } /** * @description * * Interface that a class can implement to be a guard deciding if a route can be deactivated. * If all guards return `true`, navigation continues. If any guard returns `false`, * navigation is cancelled. If any guard returns a `UrlTree`, current navigation * is cancelled and a new navigation begins to the `UrlTree` returned from the guard. * * The following example implements a `CanDeactivate` function that checks whether the * current user has permission to deactivate the requested route. * * ``` * class UserToken {} * class Permissions { * canDeactivate(user: UserToken, id: string): boolean { * return true; * } * } * ``` * * Here, the defined guard function is provided as part of the `Route` object * in the router configuration: * * ``` * * @Injectable() * class CanDeactivateTeam implements CanDeactivate { * constructor(private permissions: Permissions, private currentUser: UserToken) {} * * canDeactivate( * component: TeamComponent, * currentRoute: ActivatedRouteSnapshot, * currentState: RouterStateSnapshot, * nextState: RouterStateSnapshot * ): Observable|Promise|boolean|UrlTree { * return this.permissions.canDeactivate(this.currentUser, route.params.id); * } * } * * @NgModule({ * imports: [ * RouterModule.forRoot([ * { * path: 'team/:id', * component: TeamComponent, * canDeactivate: [CanDeactivateTeam] * } * ]) * ], * providers: [CanDeactivateTeam, UserToken, Permissions] * }) * class AppModule {} * ``` * * You can alternatively provide an in-line function with the `canDeactivate` signature: * * ``` * @NgModule({ * imports: [ * RouterModule.forRoot([ * { * path: 'team/:id', * component: TeamComponent, * canDeactivate: ['canDeactivateTeam'] * } * ]) * ], * providers: [ * { * provide: 'canDeactivateTeam', * useValue: (component: TeamComponent, currentRoute: ActivatedRouteSnapshot, currentState: * RouterStateSnapshot, nextState: RouterStateSnapshot) => true * } * ] * }) * class AppModule {} * ``` * * @publicApi */ export declare interface CanDeactivate { canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Observable | Promise | boolean | UrlTree; } /** * @description * * Interface that a class can implement to be a guard deciding if children can be loaded. * If all guards return `true`, navigation continues. If any guard returns `false`, * navigation is cancelled. If any guard returns a `UrlTree`, current navigation * is cancelled and a new navigation starts to the `UrlTree` returned from the guard. * * The following example implements a `CanLoad` function that decides whether the * current user has permission to load requested child routes. * * * ``` * class UserToken {} * class Permissions { * canLoadChildren(user: UserToken, id: string, segments: UrlSegment[]): boolean { * return true; * } * } * * @Injectable() * class CanLoadTeamSection implements CanLoad { * constructor(private permissions: Permissions, private currentUser: UserToken) {} * * canLoad(route: Route, segments: UrlSegment[]): Observable|Promise|boolean { * return this.permissions.canLoadChildren(this.currentUser, route, segments); * } * } * ``` * * Here, the defined guard function is provided as part of the `Route` object * in the router configuration: * * ``` * * @NgModule({ * imports: [ * RouterModule.forRoot([ * { * path: 'team/:id', * component: TeamComponent, * loadChildren: 'team.js', * canLoad: [CanLoadTeamSection] * } * ]) * ], * providers: [CanLoadTeamSection, UserToken, Permissions] * }) * class AppModule {} * ``` * * You can alternatively provide an in-line function with the `canLoad` signature: * * ``` * @NgModule({ * imports: [ * RouterModule.forRoot([ * { * path: 'team/:id', * component: TeamComponent, * loadChildren: 'team.js', * canLoad: ['canLoadTeamSection'] * } * ]) * ], * providers: [ * { * provide: 'canLoadTeamSection', * useValue: (route: Route, segments: UrlSegment[]) => true * } * ] * }) * class AppModule {} * ``` * * @publicApi */ export declare interface CanLoad { canLoad(route: Route, segments: UrlSegment[]): Observable | Promise | boolean | UrlTree; } /** * An event triggered at the end of the child-activation part * of the Resolve phase of routing. * @see `ChildActivationStart` * @see `ResolveStart` * @publicApi */ export declare class ChildActivationEnd { /** @docsNotRequired */ snapshot: ActivatedRouteSnapshot; constructor( /** @docsNotRequired */ snapshot: ActivatedRouteSnapshot); toString(): string; } /** * An event triggered at the start of the child-activation * part of the Resolve phase of routing. * @see `ChildActivationEnd` * @see `ResolveStart` * * @publicApi */ export declare class ChildActivationStart { /** @docsNotRequired */ snapshot: ActivatedRouteSnapshot; constructor( /** @docsNotRequired */ snapshot: ActivatedRouteSnapshot); toString(): string; } /** * Store contextual information about the children (= nested) `RouterOutlet` * * @publicApi */ export declare class ChildrenOutletContexts { private contexts; /** Called when a `RouterOutlet` directive is instantiated */ onChildOutletCreated(childName: string, outlet: RouterOutlet): void; /** * Called when a `RouterOutlet` directive is destroyed. * We need to keep the context as the outlet could be destroyed inside a NgIf and might be * re-created later. */ onChildOutletDestroyed(childName: string): void; /** * Called when the corresponding route is deactivated during navigation. * Because the component get destroyed, all children outlet are destroyed. */ onOutletDeactivated(): Map; onOutletReAttached(contexts: Map): void; getOrCreateContext(childName: string): OutletContext; getContext(childName: string): OutletContext | null; } /** * Converts a `Params` instance to a `ParamMap`. * @param params The instance to convert. * @returns The new map instance. * * @publicApi */ export declare function convertToParamMap(params: Params): ParamMap; /** * * Represents static data associated with a particular route. * * @see `Route#data` * * @publicApi */ export declare type Data = { [name: string]: any; }; /** * @description * * A default implementation of the `UrlSerializer`. * * Example URLs: * * ``` * /inbox/33(popup:compose) * /inbox/33;open=true/messages/44 * ``` * * DefaultUrlSerializer uses parentheses to serialize secondary segments (e.g., popup:compose), the * colon syntax to specify the outlet, and the ';parameter=value' syntax (e.g., open=true) to * specify route specific parameters. * * @publicApi */ export declare class DefaultUrlSerializer implements UrlSerializer { /** Parses a url into a `UrlTree` */ parse(url: string): UrlTree; /** Converts a `UrlTree` into a url */ serialize(tree: UrlTree): string; } /** * A string of the form `path/to/file#exportName` that acts as a URL for a set of routes to load. * * @see `loadChildrenCallback` * @publicApi * @deprecated The `string` form of `loadChildren` is deprecated in favor of the * `LoadChildrenCallback` function which uses the ES dynamic `import()` expression. * This offers a more natural and standards-based mechanism to dynamically * load an ES module at runtime. */ export declare type DeprecatedLoadChildren = string; /** * @description * * Represents the detached route tree. * * This is an opaque value the router will give to a custom route reuse strategy * to store and retrieve later on. * * @publicApi */ export declare type DetachedRouteHandle = {}; /** * Error handler that is invoked when a navigation error occurs. * * If the handler returns a value, the navigation Promise is resolved with this value. * If the handler throws an exception, the navigation Promise is rejected with * the exception. * * @publicApi */ declare type ErrorHandler = (error: any) => any; /** * Router events that allow you to track the lifecycle of the router. * * 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. * * @publicApi */ export declare type Event = RouterEvent | RouteConfigLoadStart | RouteConfigLoadEnd | ChildActivationStart | ChildActivationEnd | ActivationStart | ActivationEnd | Scroll; /** * A set of configuration options for a router module, provided in the * `forRoot()` method. * * @see `forRoot()` * * * @publicApi */ export declare interface ExtraOptions { /** * When true, log all internal navigation events to the console. * Use for debugging. */ enableTracing?: boolean; /** * When true, enable the location strategy that uses the URL fragment * instead of the history API. */ useHash?: boolean; /** * One of `enabled` or `disabled`. * When set to `enabled`, the initial navigation starts before the root component is created. * The bootstrap is blocked until the initial navigation is complete. This value is required for * [server-side rendering](guide/universal) to work. * When set to `disabled`, the initial navigation is not performed. * The location listener is set up before the root component gets created. * Use if there is a reason to have more control over when the router * starts its initial navigation due to some complex initialization logic. * * Legacy values are deprecated since v4 and should not be used for new applications: * * * `legacy_enabled` - Default for compatibility. * The initial navigation starts after the root component has been created, * but the bootstrap is not blocked until the initial navigation is complete. * * `legacy_disabled` - The initial navigation is not performed. * The location listener is set up after the root component gets created. * * `true` - same as `legacy_enabled`. * * `false` - same as `legacy_disabled`. */ initialNavigation?: InitialNavigation; /** * A custom error handler for failed navigations. * If the handler returns a value, the navigation Promise is resolved with this value. * If the handler throws an exception, the navigation Promise is rejected with the exception. * */ errorHandler?: ErrorHandler; /** * Configures a preloading strategy. * One of `PreloadAllModules` or `NoPreloading` (the default). */ preloadingStrategy?: any; /** * Define what the router should do if it receives a navigation request to the current URL. * Default is `ignore`, which causes the router ignores the navigation. * This can disable features such as a "refresh" button. * Use this option to configure the behavior when navigating to the * current URL. Default is 'ignore'. */ onSameUrlNavigation?: 'reload' | 'ignore'; /** * Configures if the scroll position needs to be restored when navigating back. * * * 'disabled'- (Default) Does nothing. Scroll position is maintained on navigation. * * 'top'- Sets the scroll position to x = 0, y = 0 on all navigation. * * 'enabled'- Restores the previous scroll position on backward navigation, else sets the * position to the anchor if one is provided, or sets the scroll position to [0, 0] (forward * navigation). This option will be the default in the future. * * You can implement custom scroll restoration behavior by adapting the enabled behavior as * in the following example. * * ```typescript * class AppModule { * constructor(router: Router, viewportScroller: ViewportScroller) { * router.events.pipe( * filter((e: Event): e is Scroll => e instanceof Scroll) * ).subscribe(e => { * if (e.position) { * // backward navigation * viewportScroller.scrollToPosition(e.position); * } else if (e.anchor) { * // anchor navigation * viewportScroller.scrollToAnchor(e.anchor); * } else { * // forward navigation * viewportScroller.scrollToPosition([0, 0]); * } * }); * } * } * ``` */ scrollPositionRestoration?: 'disabled' | 'enabled' | 'top'; /** * When set to 'enabled', scrolls to the anchor element when the URL has a fragment. * Anchor scrolling is disabled by default. * * Anchor scrolling does not happen on 'popstate'. Instead, we restore the position * that we stored or scroll to the top. */ anchorScrolling?: 'disabled' | 'enabled'; /** * Configures the scroll offset the router will use when scrolling to an element. * * When given a tuple with x and y position value, * the router uses that offset each time it scrolls. * When given a function, the router invokes the function every time * it restores scroll position. */ scrollOffset?: [number, number] | (() => [number, number]); /** * Defines how the router merges parameters, data, and resolved data from parent to child * routes. By default ('emptyOnly'), inherits parent parameters only for * path-less or component-less routes. * Set to 'always' to enable unconditional inheritance of parent parameters. */ paramsInheritanceStrategy?: 'emptyOnly' | 'always'; /** * A custom handler for malformed URI errors. The handler is invoked when `encodedURI` contains * invalid character sequences. * The default implementation is to redirect to the root URL, dropping * any path or parameter information. The function takes three parameters: * * - `'URIError'` - Error thrown when parsing a bad URL. * - `'UrlSerializer'` - UrlSerializer that’s configured with the router. * - `'url'` - The malformed URL that caused the URIError * */ malformedUriErrorHandler?: (error: URIError, urlSerializer: UrlSerializer, url: string) => UrlTree; /** * Defines when the router updates the browser URL. By default ('deferred'), * update after successful navigation. * Set to 'eager' if prefer to update the URL at the beginning of navigation. * Updating the URL early allows you to handle a failure of navigation by * showing an error message with the URL that failed. */ urlUpdateStrategy?: 'deferred' | 'eager'; /** * Enables a bug fix that corrects relative link resolution in components with empty paths. * Example: * * ``` * const routes = [ * { * path: '', * component: ContainerComponent, * children: [ * { path: 'a', component: AComponent }, * { path: 'b', component: BComponent }, * ] * } * ]; * ``` * * From the `ContainerComponent`, this will not work: * * `Link to A` * * However, this will work: * * `Link to A` * * In other words, you're required to use `../` rather than `./`. This is currently the default * behavior. Setting this option to `corrected` enables the fix. */ relativeLinkResolution?: 'legacy' | 'corrected'; } /** * An event triggered at the end of the Guard phase of routing. * * @see `GuardsCheckStart` * * @publicApi */ export declare class GuardsCheckEnd extends RouterEvent { /** @docsNotRequired */ urlAfterRedirects: string; /** @docsNotRequired */ state: RouterStateSnapshot; /** @docsNotRequired */ shouldActivate: boolean; constructor( /** @docsNotRequired */ id: number, /** @docsNotRequired */ url: string, /** @docsNotRequired */ urlAfterRedirects: string, /** @docsNotRequired */ state: RouterStateSnapshot, /** @docsNotRequired */ shouldActivate: boolean); toString(): string; } /** * An event triggered at the start of the Guard phase of routing. * * @see `GuardsCheckEnd` * * @publicApi */ export declare class GuardsCheckStart extends RouterEvent { /** @docsNotRequired */ urlAfterRedirects: string; /** @docsNotRequired */ state: RouterStateSnapshot; constructor( /** @docsNotRequired */ id: number, /** @docsNotRequired */ url: string, /** @docsNotRequired */ urlAfterRedirects: string, /** @docsNotRequired */ state: RouterStateSnapshot); toString(): string; } /** * Allowed values in an `ExtraOptions` object that configure * when the router performs the initial navigation operation. * * * 'enabled' - The initial navigation starts before the root component is created. * The bootstrap is blocked until the initial navigation is complete. This value is required * for [server-side rendering](guide/universal) to work. * * 'disabled' - The initial navigation is not performed. The location listener is set up before * the root component gets created. Use if there is a reason to have * more control over when the router starts its initial navigation due to some complex * initialization logic. * * The following values have been [deprecated](guide/releases#deprecation-practices) since v4, * and should not be used for new applications. * * * 'legacy_enabled'- (Default, for compatibility.) The initial navigation starts after the root * component has been created. The bootstrap is not blocked until the initial navigation is * complete. * * 'legacy_disabled'- The initial navigation is not performed. The location listener is set up * after the root component gets created. * * `true` - same as 'legacy_enabled'. * * `false` - same as 'legacy_disabled'. * * The 'legacy_enabled' and 'legacy_disabled' should not be used for new applications. * * @see `forRoot()` * * @publicApi */ export declare type InitialNavigation = true | false | 'enabled' | 'disabled' | 'legacy_enabled' | 'legacy_disabled'; /** * * A function that returns a set of routes to load. * * The string form of `LoadChildren` is deprecated (see `DeprecatedLoadChildren`). The function * form (`LoadChildrenCallback`) should be used instead. * * @see `loadChildrenCallback` * @publicApi */ export declare type LoadChildren = LoadChildrenCallback | DeprecatedLoadChildren; /** * * A function that is called to resolve a collection of lazy-loaded routes. * Must be an arrow function of the following form: * `() => import('...').then(mod => mod.MODULE)` * * For example: * * ``` * [{ * path: 'lazy', * loadChildren: () => import('./lazy-route/lazy.module').then(mod => mod.LazyModule), * }]; * ``` * * @see [Route.loadChildren](api/router/Route#loadChildren) * @publicApi */ export declare type LoadChildrenCallback = () => Type | NgModuleFactory | Observable> | Promise | Type | any>; /** * Information about a navigation operation. * Retrieve the most recent navigation object with the * [Router.getCurrentNavigation() method](api/router/Router#getcurrentnavigation) . * * * *id* : The unique identifier of the current navigation. * * *initialUrl* : The target URL passed into the `Router#navigateByUrl()` call before navigation. * This is the value before the router has parsed or applied redirects to it. * * *extractedUrl* : The initial target URL after being parsed with `UrlSerializer.extract()`. * * *finalUrl* : The extracted URL after redirects have been applied. * This URL may not be available immediately, therefore this property can be `undefined`. * It is guaranteed to be set after the `RoutesRecognized` event fires. * * *trigger* : Identifies how this navigation was triggered. * -- 'imperative'--Triggered by `router.navigateByUrl` or `router.navigate`. * -- 'popstate'--Triggered by a popstate event. * -- 'hashchange'--Triggered by a hashchange event. * * *extras* : A `NavigationExtras` options object that controlled the strategy used for this * navigation. * * *previousNavigation* : The previously successful `Navigation` object. Only one previous * navigation is available, therefore this previous `Navigation` object has a `null` value for its * own `previousNavigation`. * * @publicApi */ export declare type Navigation = { /** * The unique identifier of the current navigation. */ id: number; /** * The target URL passed into the `Router#navigateByUrl()` call before navigation. This is * the value before the router has parsed or applied redirects to it. */ initialUrl: string | UrlTree; /** * The initial target URL after being parsed with `UrlSerializer.extract()`. */ extractedUrl: UrlTree; /** * The extracted URL after redirects have been applied. * This URL may not be available immediately, therefore this property can be `undefined`. * It is guaranteed to be set after the `RoutesRecognized` event fires. */ finalUrl?: UrlTree; /** * Identifies how this navigation was triggered. * * * 'imperative'--Triggered by `router.navigateByUrl` or `router.navigate`. * * 'popstate'--Triggered by a popstate event. * * 'hashchange'--Triggered by a hashchange event. */ trigger: 'imperative' | 'popstate' | 'hashchange'; /** * Options that controlled the strategy used for this navigation. * See `NavigationExtras`. */ extras: NavigationExtras; /** * The previously successful `Navigation` object. Only one previous navigation * is available, therefore this previous `Navigation` object has a `null` value * for its own `previousNavigation`. */ previousNavigation: Navigation | null; }; /** * An event triggered when a navigation is canceled, directly or indirectly. * This can happen when a route guard * returns `false` or initiates a redirect by returning a `UrlTree`. * * @see `NavigationStart` * @see `NavigationEnd` * @see `NavigationError` * * @publicApi */ export declare class NavigationCancel extends RouterEvent { /** @docsNotRequired */ reason: string; constructor( /** @docsNotRequired */ id: number, /** @docsNotRequired */ url: string, /** @docsNotRequired */ reason: string); /** @docsNotRequired */ toString(): string; } /** * An event triggered when a navigation ends successfully. * * @see `NavigationStart` * @see `NavigationCancel` * @see `NavigationError` * * @publicApi */ export declare class NavigationEnd extends RouterEvent { /** @docsNotRequired */ urlAfterRedirects: string; constructor( /** @docsNotRequired */ id: number, /** @docsNotRequired */ url: string, /** @docsNotRequired */ urlAfterRedirects: string); /** @docsNotRequired */ toString(): string; } /** * An event triggered when a navigation fails due to an unexpected error. * * @see `NavigationStart` * @see `NavigationEnd` * @see `NavigationCancel` * * @publicApi */ export declare class NavigationError extends RouterEvent { /** @docsNotRequired */ error: any; constructor( /** @docsNotRequired */ id: number, /** @docsNotRequired */ url: string, /** @docsNotRequired */ error: any); /** @docsNotRequired */ toString(): string; } /** * @description * * Options that modify the `Router` navigation strategy. * Supply an object containing any of these properties to a `Router` navigation function to * control how the target URL should be constructed or interpreted. * * @see [Router.navigate() method](api/router/Router#navigate) * @see [Router.navigateByUrl() method](api/router/Router#navigatebyurl) * @see [Router.createUrlTree() method](api/router/Router#createurltree) * @see [Routing and Navigation guide](guide/router) * * @publicApi */ export declare interface NavigationExtras { /** * Specifies a root URI to use for relative navigation. * * For example, consider the following route configuration where the parent route * has two children. * * ``` * [{ * path: 'parent', * component: ParentComponent, * children: [{ * path: 'list', * component: ListComponent * },{ * path: 'child', * component: ChildComponent * }] * }] * ``` * * The following `go()` function navigates to the `list` route by * interpreting the destination URI as relative to the activated `child` route * * ``` * @Component({...}) * class ChildComponent { * constructor(private router: Router, private route: ActivatedRoute) {} * * go() { * this.router.navigate(['../list'], { relativeTo: this.route }); * } * } * ``` */ relativeTo?: ActivatedRoute | null; /** * Sets query parameters to the URL. * * ``` * // Navigate to /results?page=1 * this.router.navigate(['/results'], { queryParams: { page: 1 } }); * ``` */ queryParams?: Params | null; /** * Sets the hash fragment for the URL. * * ``` * // Navigate to /results#top * this.router.navigate(['/results'], { fragment: 'top' }); * ``` */ fragment?: string; /** * **DEPRECATED**: Use `queryParamsHandling: "preserve"` instead to preserve * query parameters for the next navigation. * * @deprecated since v4 */ preserveQueryParams?: boolean; /** * How to handle query parameters in the router link for the next navigation. * One of: * * `preserve` : Preserve current parameters. * * `merge` : Merge new with current parameters. * * The "preserve" option discards any new query params: * ``` * // from /view1?page=1 to/view2?page=1 * this.router.navigate(['/view2'], { queryParams: { page: 2 }, queryParamsHandling: "preserve" * }); * ``` * The "merge" option appends new query params to the params from the current URL: * ``` * // from /view1?page=1 to/view2?page=1&otherKey=2 * this.router.navigate(['/view2'], { queryParams: { otherKey: 2 }, queryParamsHandling: "merge" * }); * ``` * In case of a key collision between current parameters and those in the `queryParams` object, * the new value is used. * */ queryParamsHandling?: QueryParamsHandling | null; /** * When true, preserves the URL fragment for the next navigation * * ``` * // Preserve fragment from /results#top to /view#top * this.router.navigate(['/view'], { preserveFragment: true }); * ``` */ preserveFragment?: boolean; /** * When true, navigates without pushing a new state into history. * * ``` * // Navigate silently to /view * this.router.navigate(['/view'], { skipLocationChange: true }); * ``` */ skipLocationChange?: boolean; /** * When true, navigates while replacing the current state in history. * * ``` * // Navigate to /view * this.router.navigate(['/view'], { replaceUrl: true }); * ``` */ replaceUrl?: boolean; /** * Developer-defined state that can be passed to any navigation. * Access this value through the `Navigation.extras` object * returned from the [Router.getCurrentNavigation() * method](api/router/Router#getcurrentnavigation) while a navigation is executing. * * After a navigation completes, the router writes an object containing this * value together with a `navigationId` to `history.state`. * The value is written when `location.go()` or `location.replaceState()` * is called before activating this route. * * Note that `history.state` does not pass an object equality test because * the router adds the `navigationId` on each navigation. * */ state?: { [k: string]: any; }; } /** * An event triggered when a navigation starts. * * @publicApi */ export declare class NavigationStart extends RouterEvent { /** * Identifies the call or event that triggered the navigation. * An `imperative` trigger is a call to `router.navigateByUrl()` or `router.navigate()`. * * @see `NavigationEnd` * @see `NavigationCancel` * @see `NavigationError` */ navigationTrigger?: 'imperative' | 'popstate' | 'hashchange'; /** * The navigation state that was previously supplied to the `pushState` call, * when the navigation is triggered by a `popstate` event. Otherwise null. * * 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. * */ restoredState?: { [k: string]: any; navigationId: number; } | null; constructor( /** @docsNotRequired */ id: number, /** @docsNotRequired */ url: string, /** @docsNotRequired */ navigationTrigger?: 'imperative' | 'popstate' | 'hashchange', /** @docsNotRequired */ restoredState?: { [k: string]: any; navigationId: number; } | null); /** @docsNotRequired */ toString(): string; } /** * @description * * Provides a preloading strategy that does not preload any modules. * * This strategy is enabled by default. * * @publicApi */ export declare class NoPreloading implements PreloadingStrategy { preload(route: Route, fn: () => Observable): Observable; } /** * Store contextual information about a `RouterOutlet` * * @publicApi */ export declare class OutletContext { outlet: RouterOutlet | null; route: ActivatedRoute | null; resolver: ComponentFactoryResolver | null; children: ChildrenOutletContexts; attachRef: ComponentRef | null; } /** * A map that provides access to the required and optional parameters * specific to a route. * The map supports retrieving a single value with `get()` * or multiple values with `getAll()`. * * @see [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) * * @publicApi */ export declare interface ParamMap { /** * Reports whether the map contains a given parameter. * @param name The parameter name. * @returns True if the map contains the given parameter, false otherwise. */ has(name: string): boolean; /** * Retrieves a single value for a parameter. * @param name The parameter name. * @return The parameter's single value, * or the first value if the parameter has multiple values, * or `null` when there is no such parameter. */ get(name: string): string | null; /** * Retrieves multiple values for a parameter. * @param name The parameter name. * @return An array containing one or more values, * or an empty array if there is no such parameter. * */ getAll(name: string): string[]; /** Names of the parameters in the map. */ readonly keys: string[]; } /** * A collection of matrix and query URL parameters. * @see `convertToParamMap()` * @see `ParamMap` * * @publicApi */ export declare type Params = { [key: string]: any; }; /** * @description * * Provides a preloading strategy that preloads all modules as quickly as possible. * * ``` * RouteModule.forRoot(ROUTES, {preloadingStrategy: PreloadAllModules}) * ``` * * @publicApi */ export declare class PreloadAllModules implements PreloadingStrategy { preload(route: Route, fn: () => Observable): Observable; } /** * @description * * Provides a preloading strategy. * * @publicApi */ export declare abstract class PreloadingStrategy { abstract preload(route: Route, fn: () => Observable): Observable; } /** * The primary routing outlet. * * @publicApi */ export declare const PRIMARY_OUTLET = "primary"; /** * Registers a [DI provider](guide/glossary#provider) for a set of routes. * @param routes The route configuration to provide. * * @usageNotes * * ``` * @NgModule({ * imports: [RouterModule.forChild(ROUTES)], * providers: [provideRoutes(EXTRA_ROUTES)] * }) * class MyNgModule {} * ``` * * @publicApi */ export declare function provideRoutes(routes: Routes): any; /** * * How to handle query parameters in a router link. * One of: * - `merge` : Merge new with current parameters. * - `preserve` : Preserve current parameters. * * @see `NavigationExtras#queryParamsHandling` * @see `RouterLink` * @publicApi */ export declare type QueryParamsHandling = 'merge' | 'preserve' | ''; /** * @description * * Interface that classes can implement to be a data provider. * A data provider class can be used with the router to resolve data during navigation. * The interface defines a `resolve()` method that is invoked when the navigation starts. * The router waits for the data to be resolved before the route is finally activated. * * The following example implements a `resolve()` method that retrieves the data * needed to activate the requested route. * * ``` * @Injectable({ providedIn: 'root' }) * export class HeroResolver implements Resolve { * constructor(private service: HeroService) {} * * resolve( * route: ActivatedRouteSnapshot, * state: RouterStateSnapshot * ): Observable|Promise|any { * return this.service.getHero(route.paramMap.get('id')); * } * } * ``` * * Here, the defined `resolve()` function is provided as part of the `Route` object * in the router configuration: * * ``` * @NgModule({ * imports: [ * RouterModule.forRoot([ * { * path: 'detail/:id', * component: HeroDetailComponent, * resolve: { * hero: HeroResolver * } * } * ]) * ], * exports: [RouterModule] * }) * export class AppRoutingModule {} * ``` * * You can alternatively provide an in-line function with the `resolve()` signature: * * ``` * export const myHero: Hero = { * // ... * } * * @NgModule({ * imports: [ * RouterModule.forRoot([ * { * path: 'detail/:id', * component: HeroComponent, * resolve: { * hero: 'heroResolver' * } * } * ]) * ], * providers: [ * { * provide: 'heroResolver', * useValue: (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => myHero * } * ] * }) * export class AppModule {} * ``` * * @usageNotes * * When both guard and resolvers are specified, the resolvers are not executed until * all guards have run and succeeded. * For example, consider the following route configuration: * * ``` * { * path: 'base' * canActivate: [BaseGuard], * resolve: {data: BaseDataResolver} * children: [ * { * path: 'child', * guards: [ChildGuard], * component: ChildComponent, * resolve: {childData: ChildDataResolver} * } * ] * } * ``` * The order of execution is: BaseGuard, ChildGuard, BaseDataResolver, ChildDataResolver. * * @publicApi */ export declare interface Resolve { resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | T; } /** * * Represents the resolved data associated with a particular route. * * @see `Route#resolve`. * * @publicApi */ export declare type ResolveData = { [name: string]: any; }; /** * An event triggered at the end of the Resolve phase of routing. * @see `ResolveStart`. * * @publicApi */ export declare class ResolveEnd extends RouterEvent { /** @docsNotRequired */ urlAfterRedirects: string; /** @docsNotRequired */ state: RouterStateSnapshot; constructor( /** @docsNotRequired */ id: number, /** @docsNotRequired */ url: string, /** @docsNotRequired */ urlAfterRedirects: string, /** @docsNotRequired */ state: RouterStateSnapshot); toString(): string; } /** * An event triggered at the the start of the Resolve phase of routing. * * 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. * * @see `ResolveEnd` * * @publicApi */ export declare class ResolveStart extends RouterEvent { /** @docsNotRequired */ urlAfterRedirects: string; /** @docsNotRequired */ state: RouterStateSnapshot; constructor( /** @docsNotRequired */ id: number, /** @docsNotRequired */ url: string, /** @docsNotRequired */ urlAfterRedirects: string, /** @docsNotRequired */ state: RouterStateSnapshot); toString(): string; } /** * A configuration object that defines a single route. * A set of routes are collected in a `Routes` array to define a `Router` configuration. * The router attempts to match segments of a given URL against each route, * using the configuration options defined in this object. * * Supports static, parameterized, redirect, and wildcard routes, as well as * custom route data and resolve methods. * * For detailed usage information, see the [Routing Guide](guide/router). * * @usageNotes * * ### Simple Configuration * * The following route specifies that when navigating to, for example, * `/team/11/user/bob`, the router creates the 'Team' component * with the 'User' child component in it. * * ``` * [{ * path: 'team/:id', * component: Team, * children: [{ * path: 'user/:name', * component: User * }] * }] * ``` * * ### Multiple Outlets * * The following route creates sibling components with multiple outlets. * When navigating to `/team/11(aux:chat/jim)`, the router creates the 'Team' component next to * the 'Chat' component. The 'Chat' component is placed into the 'aux' outlet. * * ``` * [{ * path: 'team/:id', * component: Team * }, { * path: 'chat/:user', * component: Chat * outlet: 'aux' * }] * ``` * * ### Wild Cards * * The following route uses wild-card notation to specify a component * that is always instantiated regardless of where you navigate to. * * ``` * [{ * path: '**', * component: WildcardComponent * }] * ``` * * ### Redirects * * The following route uses the `redirectTo` property to ignore a segment of * a given URL when looking for a child path. * * When navigating to '/team/11/legacy/user/jim', the router changes the URL segment * '/team/11/legacy/user/jim' to '/team/11/user/jim', and then instantiates * the Team component with the User child component in it. * * ``` * [{ * path: 'team/:id', * component: Team, * children: [{ * path: 'legacy/user/:name', * redirectTo: 'user/:name' * }, { * path: 'user/:name', * component: User * }] * }] * ``` * * The redirect path can be relative, as shown in this example, or absolute. * If we change the `redirectTo` value in the example to the absolute URL segment '/user/:name', * the result URL is also absolute, '/user/jim'. * ### Empty Path * * Empty-path route configurations can be used to instantiate components that do not 'consume' * any URL segments. * * In the following configuration, when navigating to * `/team/11`, the router instantiates the 'AllUsers' component. * * ``` * [{ * path: 'team/:id', * component: Team, * children: [{ * path: '', * component: AllUsers * }, { * path: 'user/:name', * component: User * }] * }] * ``` * * Empty-path routes can have children. In the following example, when navigating * to `/team/11/user/jim`, the router instantiates the wrapper component with * the user component in it. * * Note that an empty path route inherits its parent's parameters and data. * * ``` * [{ * path: 'team/:id', * component: Team, * children: [{ * path: '', * component: WrapperCmp, * children: [{ * path: 'user/:name', * component: User * }] * }] * }] * ``` * * ### Matching Strategy * * The default path-match strategy is 'prefix', which means that the router * checks URL elements from the left to see if the URL matches a specified path. * For example, '/team/11/user' matches 'team/:id'. * * ``` * [{ * path: '', * pathMatch: 'prefix', //default * redirectTo: 'main' * }, { * path: 'main', * component: Main * }] * ``` * * You can specify the path-match strategy 'full' to make sure that the path * covers the whole unconsumed URL. It is important to do this when redirecting * empty-path routes. Otherwise, because an empty path is a prefix of any URL, * the router would apply the redirect even when navigating to the redirect destination, * creating an endless loop. * * In the following example, supplying the 'full' `pathMatch` strategy ensures * that the router applies the redirect if and only if navigating to '/'. * * ``` * [{ * path: '', * pathMatch: 'full', * redirectTo: 'main' * }, { * path: 'main', * component: Main * }] * ``` * * ### Componentless Routes * * You can share parameters between sibling components. * For example, suppose that two sibling components should go next to each other, * and both of them require an ID parameter. You can accomplish this using a route * that does not specify a component at the top level. * * In the following example, 'MainChild' and 'AuxChild' are siblings. * When navigating to 'parent/10/(a//aux:b)', the route instantiates * the main child and aux child components next to each other. * For this to work, the application component must have the primary and aux outlets defined. * * ``` * [{ * path: 'parent/:id', * children: [ * { path: 'a', component: MainChild }, * { path: 'b', component: AuxChild, outlet: 'aux' } * ] * }] * ``` * * The router merges the parameters, data, and resolve of the componentless * parent into the parameters, data, and resolve of the children. * * This is especially useful when child components are defined * with an empty path string, as in the following example. * With this configuration, navigating to '/parent/10' creates * the main child and aux components. * * ``` * [{ * path: 'parent/:id', * children: [ * { path: '', component: MainChild }, * { path: '', component: AuxChild, outlet: 'aux' } * ] * }] * ``` * * ### Lazy Loading * * Lazy loading speeds up application load time by splitting the application * into multiple bundles and loading them on demand. * To use lazy loading, provide the `loadChildren` property in the `Route` object, * instead of the `children` property. * * Given the following example route, the router will lazy load * the associated module on demand using the browser native import system. * * ``` * [{ * path: 'lazy', * loadChildren: () => import('./lazy-route/lazy.module').then(mod => mod.LazyModule), * }]; * ``` * * @publicApi */ export declare interface Route { /** * The path to match against. Cannot be used together with a custom `matcher` function. * A URL string that uses router matching notation. * Can be a wild card (`**`) that matches any URL (see Usage Notes below). * Default is "/" (the root path). * */ path?: string; /** * The path-matching strategy, one of 'prefix' or 'full'. * Default is 'prefix'. * * By default, the router checks URL elements from the left to see if the URL * matches a given path, and stops when there is a match. For example, * '/team/11/user' matches 'team/:id'. * * The path-match strategy 'full' matches against the entire URL. * It is important to do this when redirecting empty-path routes. * Otherwise, because an empty path is a prefix of any URL, * the router would apply the redirect even when navigating * to the redirect destination, creating an endless loop. * */ pathMatch?: string; /** * A custom URL-matching function. Cannot be used together with `path`. */ matcher?: UrlMatcher; /** * The component to instantiate when the path matches. * Can be empty if child routes specify components. */ component?: Type; /** * A URL to redirect to when the path matches. * Absolute if the URL begins with a slash (/), otherwise relative to the path URL. * When not present, router does not redirect. */ redirectTo?: string; /** * Name of a `RouterOutlet` object where the component can be placed * when the path matches. */ outlet?: string; /** * An array of dependency-injection tokens used to look up `CanActivate()` * handlers, in order to determine if the current user is allowed to * activate the component. By default, any user can activate. */ canActivate?: any[]; /** * An array of DI tokens used to look up `CanActivateChild()` handlers, * in order to determine if the current user is allowed to activate * a child of the component. By default, any user can activate a child. */ canActivateChild?: any[]; /** * An array of DI tokens used to look up `CanDeactivate()` * handlers, in order to determine if the current user is allowed to * deactivate the component. By default, any user can deactivate. * */ canDeactivate?: any[]; /** * An array of DI tokens used to look up `CanLoad()` * handlers, in order to determine if the current user is allowed to * load the component. By default, any user can load. */ canLoad?: any[]; /** * Additional developer-defined data provided to the component via * `ActivatedRoute`. By default, no additional data is passed. */ data?: Data; /** * A map of DI tokens used to look up data resolvers. See `Resolve`. */ resolve?: ResolveData; /** * An array of child `Route` objects that specifies a nested route * configuration. */ children?: Routes; /** * An object specifying lazy-loaded child routes. */ loadChildren?: LoadChildren; /** * Defines when guards and resolvers will be run. One of * - `paramsOrQueryParamsChange` : Run when query parameters change. * - `always` : Run on every execution. * By default, guards and resolvers run only when the matrix * parameters of the route change. */ runGuardsAndResolvers?: RunGuardsAndResolvers; } /** * An event triggered when a route has been lazy loaded. * * @see `RouteConfigLoadStart` * * @publicApi */ export declare class RouteConfigLoadEnd { /** @docsNotRequired */ route: Route; constructor( /** @docsNotRequired */ route: Route); toString(): string; } /** * An event triggered before lazy loading a route configuration. * * @see `RouteConfigLoadEnd` * * @publicApi */ export declare class RouteConfigLoadStart { /** @docsNotRequired */ route: Route; constructor( /** @docsNotRequired */ route: Route); toString(): string; } /** * @description * * A service that provides navigation among views and URL manipulation capabilities. * * @see `Route`. * @see [Routing and Navigation Guide](guide/router). * * @ngModule RouterModule * * @publicApi */ export declare class Router { private rootComponentType; private urlSerializer; private rootContexts; private location; config: Routes; private currentUrlTree; private rawUrlTree; private browserUrlTree; private readonly transitions; private navigations; private lastSuccessfulNavigation; private currentNavigation; private locationSubscription; private navigationId; private configLoader; private ngModule; private console; private isNgZoneEnabled; /** * An event stream for routing events in this NgModule. */ readonly events: Observable; /** * The current state of routing in this NgModule. */ readonly routerState: RouterState; /** * A handler for navigation errors in this NgModule. */ errorHandler: ErrorHandler; /** * A handler for errors thrown by `Router.parseUrl(url)` * when `url` contains an invalid character. * The most common case is a `%` sign * that's not encoded and is not part of a percent encoded sequence. */ malformedUriErrorHandler: (error: URIError, urlSerializer: UrlSerializer, url: string) => UrlTree; /** * True if at least one navigation event has occurred, * false otherwise. */ navigated: boolean; private lastSuccessfulId; /** * A strategy for extracting and merging URLs. * Used for AngularJS to Angular migrations. */ urlHandlingStrategy: UrlHandlingStrategy; /** * A strategy for re-using routes. */ routeReuseStrategy: RouteReuseStrategy; /** * How to handle a navigation request to the current URL. One of: * - `'ignore'` : The router ignores the request. * - `'reload'` : The router reloads the URL. Use to implement a "refresh" feature. */ onSameUrlNavigation: 'reload' | 'ignore'; /** * How to merge parameters, data, and resolved data from parent to child * routes. One of: * * - `'emptyOnly'` : Inherit parent parameters, data, and resolved data * for path-less or component-less routes. * - `'always'` : Inherit parent parameters, data, and resolved data * for all child routes. */ paramsInheritanceStrategy: 'emptyOnly' | 'always'; /** * Determines when the router updates the browser URL. * By default (`"deferred"`), updates the browser URL after navigation has finished. * Set to `'eager'` to update the browser URL at the beginning of navigation. * You can choose to update early so that, if navigation fails, * you can show an error message with the URL that failed. */ urlUpdateStrategy: 'deferred' | 'eager'; /** * Enables a bug fix that corrects relative link resolution in components with empty paths. * @see `RouterModule` */ relativeLinkResolution: 'legacy' | 'corrected'; /** * Creates the router service. */ constructor(rootComponentType: Type | null, urlSerializer: UrlSerializer, rootContexts: ChildrenOutletContexts, location: Location, injector: Injector, loader: NgModuleFactoryLoader, compiler: Compiler, config: Routes); private setupNavigations; private getTransition; private setTransition; /** * Sets up the location change listener and performs the initial navigation. */ initialNavigation(): void; /** * Sets up the location change listener. */ setUpLocationChangeListener(): void; /** The current URL. */ get url(): string; /** The current Navigation object if one exists */ getCurrentNavigation(): Navigation | null; /** * Resets the route configuration used for navigation and generating links. * * @param config The route array for the new configuration. * * @usageNotes * * ``` * router.resetConfig([ * { path: 'team/:id', component: TeamCmp, children: [ * { path: 'simple', component: SimpleCmp }, * { path: 'user/:name', component: UserCmp } * ]} * ]); * ``` */ resetConfig(config: Routes): void; /** @docsNotRequired */ ngOnDestroy(): void; /** Disposes of the router. */ dispose(): void; /** * Appends URL segments to the current URL tree to create a new URL tree. * * @param commands An array of URL fragments with which to construct the new URL tree. * If the path is static, can be the literal URL string. For a dynamic path, pass an array of path * segments, followed by the parameters for each segment. * The fragments are applied to the current URL tree or the one provided in the `relativeTo` * property of the options object, if supplied. * @param navigationExtras Options that control the navigation strategy. This function * only uses properties in `NavigationExtras` that would change the provided URL. * @returns The new URL tree. * * @usageNotes * * ``` * // create /team/33/user/11 * router.createUrlTree(['/team', 33, 'user', 11]); * * // create /team/33;expand=true/user/11 * router.createUrlTree(['/team', 33, {expand: true}, 'user', 11]); * * // you can collapse static segments like this (this works only with the first passed-in value): * router.createUrlTree(['/team/33/user', userId]); * * // If the first segment can contain slashes, and you do not want the router to split it, * // you can do the following: * router.createUrlTree([{segmentPath: '/one/two'}]); * * // create /team/33/(user/11//right:chat) * router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: 'chat'}}]); * * // remove the right secondary node * router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: null}}]); * * // assuming the current url is `/team/33/user/11` and the route points to `user/11` * * // navigate to /team/33/user/11/details * router.createUrlTree(['details'], {relativeTo: route}); * * // navigate to /team/33/user/22 * router.createUrlTree(['../22'], {relativeTo: route}); * * // navigate to /team/44/user/22 * router.createUrlTree(['../../team/44/user/22'], {relativeTo: route}); * ``` */ createUrlTree(commands: any[], navigationExtras?: NavigationExtras): UrlTree; /** * Navigates to a view using an absolute route path. * * @param url An absolute path for a defined route. The function does not apply any delta to the * current URL. * @param extras An object containing properties that modify the navigation strategy. * The function ignores any properties in the `NavigationExtras` that would change the * provided URL. * * @returns A Promise that resolves to 'true' when navigation succeeds, * to 'false' when navigation fails, or is rejected on error. * * @usageNotes * * The following calls request navigation to an absolute path. * * ``` * router.navigateByUrl("/team/33/user/11"); * * // Navigate without updating the URL * router.navigateByUrl("/team/33/user/11", { skipLocationChange: true }); * ``` * * @see [Routing and Navigation guide](guide/router) * */ navigateByUrl(url: string | UrlTree, extras?: NavigationExtras): Promise; /** * Navigate based on the provided array of commands and a starting point. * If no starting route is provided, the navigation is absolute. * * @param commands An array of URL fragments with which to construct the target URL. * If the path is static, can be the literal URL string. For a dynamic path, pass an array of path * segments, followed by the parameters for each segment. * The fragments are applied to the current URL or the one provided in the `relativeTo` property * of the options object, if supplied. * @param extras An options object that determines how the URL should be constructed or * interpreted. * * @returns A Promise that resolves to `true` when navigation succeeds, to `false` when navigation * fails, * or is rejected on error. * * @usageNotes * * The following calls request navigation to a dynamic route path relative to the current URL. * * ``` * router.navigate(['team', 33, 'user', 11], {relativeTo: route}); * * // Navigate without updating the URL, overriding the default behavior * router.navigate(['team', 33, 'user', 11], {relativeTo: route, skipLocationChange: true}); * ``` * * @see [Routing and Navigation guide](guide/router) * */ navigate(commands: any[], extras?: NavigationExtras): Promise; /** Serializes a `UrlTree` into a string */ serializeUrl(url: UrlTree): string; /** Parses a string into a `UrlTree` */ parseUrl(url: string): UrlTree; /** Returns whether the url is activated */ isActive(url: string | UrlTree, exact: boolean): boolean; private removeEmptyProps; private processNavigations; private scheduleNavigation; private setBrowserUrl; private resetStateAndUrl; private resetUrlToCurrentUrlTree; } /** * A [DI token](guide/glossary/#di-token) for the router service. * * @publicApi */ export declare const ROUTER_CONFIGURATION: InjectionToken; /** * A [DI token](guide/glossary/#di-token) for the router initializer that * is called after the app is bootstrapped. * * @publicApi */ export declare const ROUTER_INITIALIZER: InjectionToken<(compRef: ComponentRef) => void>; /** * @description * * Provides a way to customize when activated routes get reused. * * @publicApi */ export declare abstract class RouteReuseStrategy { /** Determines if this route (and its subtree) should be detached to be reused later */ abstract shouldDetach(route: ActivatedRouteSnapshot): boolean; /** * Stores the detached route. * * Storing a `null` value should erase the previously stored value. */ abstract store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle | null): void; /** Determines if this route (and its subtree) should be reattached */ abstract shouldAttach(route: ActivatedRouteSnapshot): boolean; /** Retrieves the previously stored route */ abstract retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null; /** Determines if a route should be reused */ abstract shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean; } /** * Base for events the router goes through, as opposed to events tied to a specific * route. Fired one time for any given navigation. * * The following code shows how a class subscribes to router events. * * ```ts * class MyService { * constructor(public router: Router, logger: Logger) { * router.events.pipe( * filter((e: Event): e is RouterEvent => e instanceof RouterEvent) * ).subscribe((e: RouterEvent) => { * logger.log(e.id, e.url); * }); * } * } * ``` * * @see `Event` * @see [Router events summary](guide/router#router-events) * @publicApi */ export declare class RouterEvent { /** A unique ID that the router assigns to every router navigation. */ id: number; /** The URL that is the destination for this navigation. */ url: string; constructor( /** A unique ID that the router assigns to every router navigation. */ id: number, /** The URL that is the destination for this navigation. */ url: string); } /** * @description * * Lets you link to specific routes in your app. * * Consider the following route configuration: * `[{ path: 'user/:name', component: UserCmp }]`. * When linking to this `user/:name` route, you use the `RouterLink` directive. * * If the link is static, you can use the directive as follows: * `link to user component` * * If you use dynamic values to generate the link, you can pass an array of path * segments, followed by the params for each segment. * * For instance `['/team', teamId, 'user', userName, {details: true}]` * means that we want to generate a link to `/team/11/user/bob;details=true`. * * Multiple static segments can be merged into one * (e.g., `['/team/11/user', userName, {details: true}]`). * * The first segment name can be prepended with `/`, `./`, or `../`: * * If the first segment begins with `/`, the router will look up the route from the root of the * app. * * If the first segment begins with `./`, or doesn't begin with a slash, the router will * instead look in the children of the current activated route. * * And if the first segment begins with `../`, the router will go up one level. * * You can set query params and fragment as follows: * * ``` * * link to user component * * ``` * RouterLink will use these to generate this link: `/user/bob?debug=true#education`. * * (Deprecated in v4.0.0 use `queryParamsHandling` instead) You can also tell the * directive to preserve the current query params and fragment: * * ``` * * link to user component * * ``` * * You can tell the directive how to handle queryParams. Available options are: * - `'merge'`: merge the queryParams into the current queryParams * - `'preserve'`: preserve the current queryParams * - default/`''`: use the queryParams only * * Same options for {@link NavigationExtras#queryParamsHandling * NavigationExtras#queryParamsHandling}. * * ``` * * link to user component * * ``` * * You can provide a `state` value to be persisted to the browser's History.state * property (See https://developer.mozilla.org/en-US/docs/Web/API/History#Properties). It's * used as follows: * * ``` * * link to user component * * ``` * * And later the value can be read from the router through `router.getCurrentNavigation`. * For example, to capture the `tracingId` above during the `NavigationStart` event: * * ``` * // Get NavigationStart events * router.events.pipe(filter(e => e instanceof NavigationStart)).subscribe(e => { * const navigation = router.getCurrentNavigation(); * tracingService.trace({id: navigation.extras.state.tracingId}); * }); * ``` * * The router link directive always treats the provided input as a delta to the current url. * * For instance, if the current url is `/user/(box//aux:team)`. * * Then the following link `Jim` will generate the link * `/user/(jim//aux:team)`. * * See {@link Router#createUrlTree createUrlTree} for more information. * * @ngModule RouterModule * * @publicApi */ export declare class RouterLink { private router; private route; /** * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`. * @see {@link NavigationExtras#queryParams NavigationExtras#queryParams} * @see {@link Router#createUrlTree Router#createUrlTree} */ queryParams: { [k: string]: any; }; /** * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`. * @see {@link NavigationExtras#fragment NavigationExtras#fragment} * @see {@link Router#createUrlTree Router#createUrlTree} */ fragment: string; /** * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`. * @see {@link NavigationExtras#queryParamsHandling NavigationExtras#queryParamsHandling} * @see {@link Router#createUrlTree Router#createUrlTree} */ queryParamsHandling: QueryParamsHandling; /** * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`. * @see {@link NavigationExtras#preserveFragment NavigationExtras#preserveFragment} * @see {@link Router#createUrlTree Router#createUrlTree} */ preserveFragment: boolean; /** * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`. * @see {@link NavigationExtras#skipLocationChange NavigationExtras#skipLocationChange} * @see {@link Router#createUrlTree Router#createUrlTree} */ skipLocationChange: boolean; /** * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`. * @see {@link NavigationExtras#replaceUrl NavigationExtras#replaceUrl} * @see {@link Router#createUrlTree Router#createUrlTree} */ replaceUrl: boolean; /** * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`. * @see {@link NavigationExtras#state NavigationExtras#state} * @see {@link Router#createUrlTree Router#createUrlTree} */ state?: { [k: string]: any; }; private commands; private preserve; constructor(router: Router, route: ActivatedRoute, tabIndex: string, renderer: Renderer2, el: ElementRef); /** * Commands to pass to {@link Router#createUrlTree Router#createUrlTree}. * - **array**: commands to pass to {@link Router#createUrlTree Router#createUrlTree}. * - **string**: shorthand for array of commands with just the string, i.e. `['/route']` * - **null|undefined**: shorthand for an empty array of commands, i.e. `[]` * @see {@link Router#createUrlTree Router#createUrlTree} */ set routerLink(commands: any[] | string | null | undefined); /** * @deprecated As of Angular v4.0 use `queryParamsHandling` instead. */ set preserveQueryParams(value: boolean); onClick(): boolean; get urlTree(): UrlTree; } /** * * @description * * Lets you add a CSS class to an element when the link's route becomes active. * * This directive lets you add a CSS class to an element when the link's route * becomes active. * * Consider the following example: * * ``` * Bob * ``` * * When the url is either '/user' or '/user/bob', the active-link class will * be added to the `a` tag. If the url changes, the class will be removed. * * You can set more than one class, as follows: * * ``` * Bob * Bob * ``` * * You can configure RouterLinkActive by passing `exact: true`. This will add the classes * only when the url matches the link exactly. * * ``` * Bob * ``` * * You can assign the RouterLinkActive instance to a template variable and directly check * the `isActive` status. * ``` * * Bob {{ rla.isActive ? '(already open)' : ''}} * * ``` * * Finally, you can apply the RouterLinkActive directive to an ancestor of a RouterLink. * * ``` *
* Jim * Bob *
* ``` * * This will set the active-link class on the div tag if the url is either '/user/jim' or * '/user/bob'. * * @ngModule RouterModule * * @publicApi */ export declare class RouterLinkActive implements OnChanges, OnDestroy, AfterContentInit { private router; private element; private renderer; private readonly cdr; private link?; private linkWithHref?; links: QueryList; linksWithHrefs: QueryList; private classes; private subscription; readonly isActive: boolean; routerLinkActiveOptions: { exact: boolean; }; constructor(router: Router, element: ElementRef, renderer: Renderer2, cdr: ChangeDetectorRef, link?: RouterLink | undefined, linkWithHref?: RouterLinkWithHref | undefined); ngAfterContentInit(): void; set routerLinkActive(data: string[] | string); ngOnChanges(changes: SimpleChanges): void; ngOnDestroy(): void; private update; private isLinkActive; private hasActiveLinks; } /** * @description * * Lets you link to specific routes in your app. * * See `RouterLink` for more information. * * @ngModule RouterModule * * @publicApi */ export declare class RouterLinkWithHref implements OnChanges, OnDestroy { private router; private route; private locationStrategy; target: string; /** * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`. * @see {@link NavigationExtras#queryParams NavigationExtras#queryParams} * @see {@link Router#createUrlTree Router#createUrlTree} */ queryParams: { [k: string]: any; }; /** * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`. * @see {@link NavigationExtras#fragment NavigationExtras#fragment} * @see {@link Router#createUrlTree Router#createUrlTree} */ fragment: string; /** * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`. * @see {@link NavigationExtras#queryParamsHandling NavigationExtras#queryParamsHandling} * @see {@link Router#createUrlTree Router#createUrlTree} */ queryParamsHandling: QueryParamsHandling; /** * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`. * @see {@link NavigationExtras#preserveFragment NavigationExtras#preserveFragment} * @see {@link Router#createUrlTree Router#createUrlTree} */ preserveFragment: boolean; /** * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`. * @see {@link NavigationExtras#skipLocationChange NavigationExtras#skipLocationChange} * @see {@link Router#createUrlTree Router#createUrlTree} */ skipLocationChange: boolean; /** * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`. * @see {@link NavigationExtras#replaceUrl NavigationExtras#replaceUrl} * @see {@link Router#createUrlTree Router#createUrlTree} */ replaceUrl: boolean; /** * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`. * @see {@link NavigationExtras#state NavigationExtras#state} * @see {@link Router#createUrlTree Router#createUrlTree} */ state?: { [k: string]: any; }; private commands; private subscription; private preserve; href: string; constructor(router: Router, route: ActivatedRoute, locationStrategy: LocationStrategy); /** * Commands to pass to {@link Router#createUrlTree Router#createUrlTree}. * - **array**: commands to pass to {@link Router#createUrlTree Router#createUrlTree}. * - **string**: shorthand for array of commands with just the string, i.e. `['/route']` * - **null|undefined**: shorthand for an empty array of commands, i.e. `[]` * @see {@link Router#createUrlTree Router#createUrlTree} */ set routerLink(commands: any[] | string | null | undefined); /** * @deprecated As of Angular v4.0 use `queryParamsHandling` instead. */ set preserveQueryParams(value: boolean); ngOnChanges(changes: {}): any; ngOnDestroy(): any; onClick(button: number, ctrlKey: boolean, metaKey: boolean, shiftKey: boolean): boolean; private updateTargetUrlAndHref; get urlTree(): UrlTree; } /** * @description * * Adds directives and providers for in-app navigation among views defined in an application. * Use the Angular `Router` service to declaratively specify application states and manage state * transitions. * * You can import this NgModule multiple times, once for each lazy-loaded bundle. * However, only one `Router` service can be active. * To ensure this, there are two ways to register routes when importing this module: * * * The `forRoot()` method creates an `NgModule` that contains all the directives, the given * routes, and the `Router` service itself. * * The `forChild()` method creates an `NgModule` that contains all the directives and the given * routes, but does not include the `Router` service. * * @see [Routing and Navigation guide](guide/router) for an * overview of how the `Router` service should be used. * * @publicApi */ export declare class RouterModule { constructor(guard: any, router: Router); /** * Creates and configures a module with all the router providers and directives. * Optionally sets up an application listener to perform an initial navigation. * * When registering the NgModule at the root, import as follows: * * ``` * @NgModule({ * imports: [RouterModule.forRoot(ROUTES)] * }) * class MyNgModule {} * ``` * * @param routes An array of `Route` objects that define the navigation paths for the application. * @param config An `ExtraOptions` configuration object that controls how navigation is performed. * @return The new `NgModule`. * */ static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders; /** * Creates a module with all the router directives and a provider registering routes, * without creating a new Router service. * When registering for submodules and lazy-loaded submodules, create the NgModule as follows: * * ``` * @NgModule({ * imports: [RouterModule.forChild(ROUTES)] * }) * class MyNgModule {} * ``` * * @param routes An array of `Route` objects that define the navigation paths for the submodule. * @return The new NgModule. * */ static forChild(routes: Routes): ModuleWithProviders; } /** * @description * * Acts as a placeholder that Angular dynamically fills based on the current router state. * * Each outlet can have a unique name, determined by the optional `name` attribute. * The name cannot be set or changed dynamically. If not set, default value is "primary". * * ``` * * * * ``` * * A router outlet emits an activate event when a new component is instantiated, * and a deactivate event when a component is destroyed. * * ``` * * ``` * @ngModule RouterModule * * @publicApi */ export declare class RouterOutlet implements OnDestroy, OnInit { private parentContexts; private location; private resolver; private changeDetector; private activated; private _activatedRoute; private name; activateEvents: EventEmitter; deactivateEvents: EventEmitter; constructor(parentContexts: ChildrenOutletContexts, location: ViewContainerRef, resolver: ComponentFactoryResolver, name: string, changeDetector: ChangeDetectorRef); ngOnDestroy(): void; ngOnInit(): void; get isActivated(): boolean; get component(): Object; get activatedRoute(): ActivatedRoute; get activatedRouteData(): Data; /** * Called when the `RouteReuseStrategy` instructs to detach the subtree */ detach(): ComponentRef; /** * Called when the `RouteReuseStrategy` instructs to re-attach a previously detached subtree */ attach(ref: ComponentRef, activatedRoute: ActivatedRoute): void; deactivate(): void; activateWith(activatedRoute: ActivatedRoute, resolver: ComponentFactoryResolver | null): void; } /** * The preloader optimistically loads all router configurations to * make navigations into lazily-loaded sections of the application faster. * * The preloader runs in the background. When the router bootstraps, the preloader * starts listening to all navigation events. After every such event, the preloader * will check if any configurations can be loaded lazily. * * If a route is protected by `canLoad` guards, the preloaded will not load it. * * @publicApi */ export declare class RouterPreloader implements OnDestroy { private router; private injector; private preloadingStrategy; private loader; private subscription; constructor(router: Router, moduleLoader: NgModuleFactoryLoader, compiler: Compiler, injector: Injector, preloadingStrategy: PreloadingStrategy); setUpPreloading(): void; preload(): Observable; ngOnDestroy(): void; private processRoutes; private preloadConfig; } /** * Represents the state of the router as a tree of activated routes. * * @usageNotes * * Every node in the route tree is an `ActivatedRoute` instance * that knows about the "consumed" URL segments, the extracted parameters, * and the resolved data. * Use the `ActivatedRoute` properties to traverse the tree from any node. * * The following fragment shows how a component gets the root node * of the current state to establish its own route tree: * * ``` * @Component({templateUrl:'template.html'}) * class MyComponent { * constructor(router: Router) { * const state: RouterState = router.routerState; * const root: ActivatedRoute = state.root; * const child = root.firstChild; * const id: Observable = child.params.map(p => p.id); * //... * } * } * ``` * * @see `ActivatedRoute` * @see [Getting route information](guide/router#getting-route-information) * * @publicApi */ export declare class RouterState extends ɵangular_packages_router_router_m { /** The current snapshot of the router state */ snapshot: RouterStateSnapshot; toString(): string; } /** * @description * * 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. * * The following example shows how a component is initialized with information * from the snapshot of the root node's state at the time of creation. * * ``` * @Component({templateUrl:'template.html'}) * class MyComponent { * constructor(router: Router) { * const state: RouterState = router.routerState; * const snapshot: RouterStateSnapshot = state.snapshot; * const root: ActivatedRouteSnapshot = snapshot.root; * const child = root.firstChild; * const id: Observable = child.params.map(p => p.id); * //... * } * } * ``` * * @publicApi */ export declare class RouterStateSnapshot extends ɵangular_packages_router_router_m { /** The url from which this snapshot was created */ url: string; toString(): string; } /** * The [DI token](guide/glossary/#di-token) for a router configuration. * @see `ROUTES` * @publicApi */ export declare const ROUTES: InjectionToken; /** * Represents a route configuration for the Router service. * An array of `Route` objects, used in `Router.config` and for nested route configurations * in `Route.children`. * * @see `Route` * @see `Router` * @see [Router configuration guide](guide/router#configuration) * @publicApi */ export declare type Routes = Route[]; /** * An event triggered when routes are recognized. * * @publicApi */ export declare class RoutesRecognized extends RouterEvent { /** @docsNotRequired */ urlAfterRedirects: string; /** @docsNotRequired */ state: RouterStateSnapshot; constructor( /** @docsNotRequired */ id: number, /** @docsNotRequired */ url: string, /** @docsNotRequired */ urlAfterRedirects: string, /** @docsNotRequired */ state: RouterStateSnapshot); /** @docsNotRequired */ toString(): string; } /** * * A policy for when to run guards and resolvers on a route. * * @see [Route.runGuardsAndResolvers](api/router/Route#runGuardsAndResolvers) * @publicApi */ export declare type RunGuardsAndResolvers = 'pathParamsChange' | 'pathParamsOrQueryParamsChange' | 'paramsChange' | 'paramsOrQueryParamsChange' | 'always' | ((from: ActivatedRouteSnapshot, to: ActivatedRouteSnapshot) => boolean); /** * An event triggered by scrolling. * * @publicApi */ export declare class Scroll { /** @docsNotRequired */ readonly routerEvent: NavigationEnd; /** @docsNotRequired */ readonly position: [number, number] | null; /** @docsNotRequired */ readonly anchor: string | null; constructor( /** @docsNotRequired */ routerEvent: NavigationEnd, /** @docsNotRequired */ position: [number, number] | null, /** @docsNotRequired */ anchor: string | null); toString(): string; } /** * @description * * Provides a way to migrate AngularJS applications to Angular. * * @publicApi */ export declare abstract class UrlHandlingStrategy { /** * Tells the router if this URL should be processed. * * When it returns true, the router will execute the regular navigation. * When it returns false, the router will set the router state to an empty state. * As a result, all the active components will be destroyed. * */ abstract shouldProcessUrl(url: UrlTree): boolean; /** * Extracts the part of the URL that should be handled by the router. * The rest of the URL will remain untouched. */ abstract extract(url: UrlTree): UrlTree; /** * Merges the URL fragment with the rest of the URL. */ abstract merge(newUrlPart: UrlTree, rawUrl: UrlTree): UrlTree; } /** * A function for matching a route against URLs. Implement a custom URL matcher * for `Route.matcher` when a combination of `path` and `pathMatch` * is not expressive enough. Cannot be used together with `path` and `pathMatch`. * * The function takes the following arguments and returns a `UrlMatchResult` object. * * *segments* : An array of URL segments. * * *group* : A segment group. * * *route* : The route to match against. * * The following example implementation matches HTML files. * * ``` * export function htmlFiles(url: UrlSegment[]) { * return url.length === 1 && url[0].path.endsWith('.html') ? ({consumed: url}) : null; * } * * export const routes = [{ matcher: htmlFiles, component: AnyComponent }]; * ``` * * @publicApi */ export declare type UrlMatcher = (segments: UrlSegment[], group: UrlSegmentGroup, route: Route) => UrlMatchResult | null; /** * Represents the result of matching URLs with a custom matching function. * * * `consumed` is an array of the consumed URL segments. * * `posParams` is a map of positional parameters. * * @see `UrlMatcher()` * @publicApi */ export declare type UrlMatchResult = { consumed: UrlSegment[]; posParams?: { [name: string]: UrlSegment; }; }; /** * @description * * Represents a single URL segment. * * A UrlSegment is a part of a URL between the two slashes. It contains a path and the matrix * parameters associated with the segment. * * @usageNotes * ### Example * * ``` * @Component({templateUrl:'template.html'}) * class MyComponent { * constructor(router: Router) { * const tree: UrlTree = router.parseUrl('/team;id=33'); * const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET]; * const s: UrlSegment[] = g.segments; * s[0].path; // returns 'team' * s[0].parameters; // returns {id: 33} * } * } * ``` * * @publicApi */ export declare class UrlSegment { /** The path part of a URL segment */ path: string; /** The matrix parameters associated with a segment */ parameters: { [name: string]: string; }; constructor( /** The path part of a URL segment */ path: string, /** The matrix parameters associated with a segment */ parameters: { [name: string]: string; }); get parameterMap(): ParamMap; /** @docsNotRequired */ toString(): string; } /** * @description * * Represents the parsed URL segment group. * * See `UrlTree` for more information. * * @publicApi */ export declare class UrlSegmentGroup { /** The URL segments of this group. See `UrlSegment` for more information */ segments: UrlSegment[]; /** The list of children of this group */ children: { [key: string]: UrlSegmentGroup; }; /** The parent node in the url tree */ parent: UrlSegmentGroup | null; constructor( /** The URL segments of this group. See `UrlSegment` for more information */ segments: UrlSegment[], /** The list of children of this group */ children: { [key: string]: UrlSegmentGroup; }); /** Whether the segment has child segments */ hasChildren(): boolean; /** Number of child segments */ get numberOfChildren(): number; /** @docsNotRequired */ toString(): string; } /** * @description * * Serializes and deserializes a URL string into a URL tree. * * The url serialization strategy is customizable. You can * make all URLs case insensitive by providing a custom UrlSerializer. * * See `DefaultUrlSerializer` for an example of a URL serializer. * * @publicApi */ export declare abstract class UrlSerializer { /** Parse a url into a `UrlTree` */ abstract parse(url: string): UrlTree; /** Converts a `UrlTree` into a url */ abstract serialize(tree: UrlTree): string; } /** * @description * * Represents the parsed URL. * * Since a router state is a tree, and the URL is nothing but a serialized state, the URL is a * serialized tree. * UrlTree is a data structure that provides a lot of affordances in dealing with URLs * * @usageNotes * ### Example * * ``` * @Component({templateUrl:'template.html'}) * class MyComponent { * constructor(router: Router) { * const tree: UrlTree = * router.parseUrl('/team/33/(user/victor//support:help)?debug=true#fragment'); * const f = tree.fragment; // return 'fragment' * const q = tree.queryParams; // returns {debug: 'true'} * const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET]; * const s: UrlSegment[] = g.segments; // returns 2 segments 'team' and '33' * g.children[PRIMARY_OUTLET].segments; // returns 2 segments 'user' and 'victor' * g.children['support'].segments; // return 1 segment 'help' * } * } * ``` * * @publicApi */ export declare class UrlTree { /** The root segment group of the URL tree */ root: UrlSegmentGroup; /** The query params of the URL */ queryParams: Params; /** The fragment of the URL */ fragment: string | null; get queryParamMap(): ParamMap; /** @docsNotRequired */ toString(): string; } /** * @publicApi */ export declare const VERSION: Version; /** * @docsNotRequired */ export declare const ɵangular_packages_router_router_a: InjectionToken; export declare function ɵangular_packages_router_router_b(): NgProbeToken; export declare function ɵangular_packages_router_router_c(router: Router, viewportScroller: ViewportScroller, config: ExtraOptions): ɵangular_packages_router_router_o; export declare function ɵangular_packages_router_router_d(platformLocationStrategy: PlatformLocation, baseHref: string, options?: ExtraOptions): HashLocationStrategy | PathLocationStrategy; export declare function ɵangular_packages_router_router_e(router: Router): any; export declare function ɵangular_packages_router_router_f(urlSerializer: UrlSerializer, contexts: ChildrenOutletContexts, location: Location, injector: Injector, loader: NgModuleFactoryLoader, compiler: Compiler, config: Route[][], opts?: ExtraOptions, urlHandlingStrategy?: UrlHandlingStrategy, routeReuseStrategy?: RouteReuseStrategy): Router; export declare function ɵangular_packages_router_router_g(router: Router): ActivatedRoute; /** * Router initialization requires two steps: * * First, we start the navigation in a `APP_INITIALIZER` to block the bootstrap if * a resolver or a guard executes asynchronously. * * Next, we actually run activation in a `BOOTSTRAP_LISTENER`, using the * `afterPreactivation` hook provided by the router. * The router navigation starts, reaches the point when preactivation is done, and then * pauses. It waits for the hook to be resolved. We then resolve it only in a bootstrap listener. */ export declare class ɵangular_packages_router_router_h { private injector; private initNavigation; private resultOfPreactivationDone; constructor(injector: Injector); appInitializer(): Promise; bootstrapListener(bootstrappedComponentRef: ComponentRef): void; private isLegacyEnabled; private isLegacyDisabled; } export declare function ɵangular_packages_router_router_i(r: ɵangular_packages_router_router_h): () => Promise; export declare function ɵangular_packages_router_router_j(r: ɵangular_packages_router_router_h): (bootstrappedComponentRef: ComponentRef) => void; export declare function ɵangular_packages_router_router_k(): (typeof ɵangular_packages_router_router_h | { provide: InjectionToken<(() => void)[]>; multi: boolean; useFactory: typeof ɵangular_packages_router_router_i; deps: (typeof ɵangular_packages_router_router_h)[]; useExisting?: undefined; } | { provide: InjectionToken<(compRef: ComponentRef) => void>; useFactory: typeof ɵangular_packages_router_router_j; deps: (typeof ɵangular_packages_router_router_h)[]; multi?: undefined; useExisting?: undefined; } | { provide: InjectionToken<((compRef: ComponentRef) => void)[]>; multi: boolean; useExisting: InjectionToken<(compRef: ComponentRef) => void>; useFactory?: undefined; deps?: undefined; })[]; export declare class ɵangular_packages_router_router_m { constructor(root: ɵangular_packages_router_router_n); get root(): T; } export declare class ɵangular_packages_router_router_n { value: T; children: ɵangular_packages_router_router_n[]; constructor(value: T, children: ɵangular_packages_router_router_n[]); toString(): string; } export declare class ɵangular_packages_router_router_o implements OnDestroy { private router; /** @docsNotRequired */ readonly viewportScroller: ViewportScroller; private options; private routerEventsSubscription; private scrollEventsSubscription; private lastId; private lastSource; private restoredId; private store; constructor(router: Router, /** @docsNotRequired */ viewportScroller: ViewportScroller, options?: { scrollPositionRestoration?: 'disabled' | 'enabled' | 'top'; anchorScrolling?: 'disabled' | 'enabled'; }); init(): void; private createScrollEvents; private consumeScrollEvents; private scheduleScrollEvent; ngOnDestroy(): void; } /** * This component is used internally within the router to be a placeholder when an empty * router-outlet is needed. For example, with a config such as: * * `{path: 'parent', outlet: 'nav', children: [...]}` * * In order to render, there needs to be a component on this config, which will default * to this `EmptyOutletComponent`. */ declare class ɵEmptyOutletComponent { } export { ɵEmptyOutletComponent } export { ɵEmptyOutletComponent as ɵangular_packages_router_router_l } /** * Flattens single-level nested arrays. */ export declare function ɵflatten(arr: T[][]): T[]; export declare const ɵROUTER_PROVIDERS: Provider[]; export { }