UNPKG

111 kBTypeScriptView Raw
1/**
2 * @license Angular v10.0.9
3 * (c) 2010-2020 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7import { AfterContentInit } from '@angular/core';
8import { ChangeDetectorRef } from '@angular/core';
9import { Compiler } from '@angular/core';
10import { ComponentFactoryResolver } from '@angular/core';
11import { ComponentRef } from '@angular/core';
12import { ElementRef } from '@angular/core';
13import { EventEmitter } from '@angular/core';
14import { HashLocationStrategy } from '@angular/common';
15import { InjectionToken } from '@angular/core';
16import { Injector } from '@angular/core';
17import { Location } from '@angular/common';
18import { LocationStrategy } from '@angular/common';
19import { ModuleWithProviders } from '@angular/core';
20import { NgModuleFactory } from '@angular/core';
21import { NgModuleFactoryLoader } from '@angular/core';
22import { NgProbeToken } from '@angular/core';
23import { Observable } from 'rxjs';
24import { OnChanges } from '@angular/core';
25import { OnDestroy } from '@angular/core';
26import { OnInit } from '@angular/core';
27import { PathLocationStrategy } from '@angular/common';
28import { PlatformLocation } from '@angular/common';
29import { Provider } from '@angular/core';
30import { QueryList } from '@angular/core';
31import { Renderer2 } from '@angular/core';
32import { SimpleChanges } from '@angular/core';
33import { Type } from '@angular/core';
34import { Version } from '@angular/core';
35import { ViewContainerRef } from '@angular/core';
36import { ViewportScroller } from '@angular/common';
37
38/**
39 * Provides access to information about a route associated with a component
40 * that is loaded in an outlet.
41 * Use to traverse the `RouterState` tree and extract information from nodes.
42 *
43 * The following example shows how to construct a component using information from a
44 * currently activated route.
45 *
46 * {@example router/activated-route/module.ts region="activated-route"
47 * header="activated-route.component.ts"}
48 *
49 * @see [Getting route information](guide/router#getting-route-information)
50 *
51 * @publicApi
52 */
53export declare class ActivatedRoute {
54 /** An observable of the URL segments matched by this route. */
55 url: Observable<UrlSegment[]>;
56 /** An observable of the matrix parameters scoped to this route. */
57 params: Observable<Params>;
58 /** An observable of the query parameters shared by all the routes. */
59 queryParams: Observable<Params>;
60 /** An observable of the URL fragment shared by all the routes. */
61 fragment: Observable<string>;
62 /** An observable of the static and resolved data of this route. */
63 data: Observable<Data>;
64 /** The outlet name of the route, a constant. */
65 outlet: string;
66 /** The component of the route, a constant. */
67 component: Type<any> | string | null;
68 /** The current snapshot of this route */
69 snapshot: ActivatedRouteSnapshot;
70 /** The configuration used to match this route. */
71 get routeConfig(): Route | null;
72 /** The root of the router state. */
73 get root(): ActivatedRoute;
74 /** The parent of this route in the router state tree. */
75 get parent(): ActivatedRoute | null;
76 /** The first child of this route in the router state tree. */
77 get firstChild(): ActivatedRoute | null;
78 /** The children of this route in the router state tree. */
79 get children(): ActivatedRoute[];
80 /** The path from the root of the router state tree to this route. */
81 get pathFromRoot(): ActivatedRoute[];
82 /**
83 * An Observable that contains a map of the required and optional parameters
84 * specific to the route.
85 * The map supports retrieving single and multiple values from the same parameter.
86 */
87 get paramMap(): Observable<ParamMap>;
88 /**
89 * An Observable that contains a map of the query parameters available to all routes.
90 * The map supports retrieving single and multiple values from the query parameter.
91 */
92 get queryParamMap(): Observable<ParamMap>;
93 toString(): string;
94}
95
96/**
97 * @description
98 *
99 * Contains the information about a route associated with a component loaded in an
100 * outlet at a particular moment in time. ActivatedRouteSnapshot can also be used to
101 * traverse the router state tree.
102 *
103 * The following example initializes a component with route information extracted
104 * from the snapshot of the root node at the time of creation.
105 *
106 * ```
107 * @Component({templateUrl:'./my-component.html'})
108 * class MyComponent {
109 * constructor(route: ActivatedRoute) {
110 * const id: string = route.snapshot.params.id;
111 * const url: string = route.snapshot.url.join('');
112 * const user = route.snapshot.data.user;
113 * }
114 * }
115 * ```
116 *
117 * @publicApi
118 */
119export declare class ActivatedRouteSnapshot {
120 /** The URL segments matched by this route */
121 url: UrlSegment[];
122 /** The matrix parameters scoped to this route */
123 params: Params;
124 /** The query parameters shared by all the routes */
125 queryParams: Params;
126 /** The URL fragment shared by all the routes */
127 fragment: string;
128 /** The static and resolved data of this route */
129 data: Data;
130 /** The outlet name of the route */
131 outlet: string;
132 /** The component of the route */
133 component: Type<any> | string | null;
134 /** The configuration used to match this route **/
135 readonly routeConfig: Route | null;
136 /** The root of the router state */
137 get root(): ActivatedRouteSnapshot;
138 /** The parent of this route in the router state tree */
139 get parent(): ActivatedRouteSnapshot | null;
140 /** The first child of this route in the router state tree */
141 get firstChild(): ActivatedRouteSnapshot | null;
142 /** The children of this route in the router state tree */
143 get children(): ActivatedRouteSnapshot[];
144 /** The path from the root of the router state tree to this route */
145 get pathFromRoot(): ActivatedRouteSnapshot[];
146 get paramMap(): ParamMap;
147 get queryParamMap(): ParamMap;
148 toString(): string;
149}
150
151/**
152 * An event triggered at the end of the activation part
153 * of the Resolve phase of routing.
154 * @see `ActivationStart`
155 * @see `ResolveStart`
156 *
157 * @publicApi
158 */
159export declare class ActivationEnd {
160 /** @docsNotRequired */
161 snapshot: ActivatedRouteSnapshot;
162 constructor(
163 /** @docsNotRequired */
164 snapshot: ActivatedRouteSnapshot);
165 toString(): string;
166}
167
168/**
169 * An event triggered at the start of the activation part
170 * of the Resolve phase of routing.
171 * @see `ActivationEnd`
172 * @see `ResolveStart`
173 *
174 * @publicApi
175 */
176export declare class ActivationStart {
177 /** @docsNotRequired */
178 snapshot: ActivatedRouteSnapshot;
179 constructor(
180 /** @docsNotRequired */
181 snapshot: ActivatedRouteSnapshot);
182 toString(): string;
183}
184
185/**
186 * @description
187 *
188 * Interface that a class can implement to be a guard deciding if a route can be activated.
189 * If all guards return `true`, navigation continues. If any guard returns `false`,
190 * navigation is cancelled. If any guard returns a `UrlTree`, the current navigation
191 * is cancelled and a new navigation begins to the `UrlTree` returned from the guard.
192 *
193 * The following example implements a `CanActivate` function that checks whether the
194 * current user has permission to activate the requested route.
195 *
196 * ```
197 * class UserToken {}
198 * class Permissions {
199 * canActivate(user: UserToken, id: string): boolean {
200 * return true;
201 * }
202 * }
203 *
204 * @Injectable()
205 * class CanActivateTeam implements CanActivate {
206 * constructor(private permissions: Permissions, private currentUser: UserToken) {}
207 *
208 * canActivate(
209 * route: ActivatedRouteSnapshot,
210 * state: RouterStateSnapshot
211 * ): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean|UrlTree {
212 * return this.permissions.canActivate(this.currentUser, route.params.id);
213 * }
214 * }
215 * ```
216 *
217 * Here, the defined guard function is provided as part of the `Route` object
218 * in the router configuration:
219 *
220 * ```
221 * @NgModule({
222 * imports: [
223 * RouterModule.forRoot([
224 * {
225 * path: 'team/:id',
226 * component: TeamComponent,
227 * canActivate: [CanActivateTeam]
228 * }
229 * ])
230 * ],
231 * providers: [CanActivateTeam, UserToken, Permissions]
232 * })
233 * class AppModule {}
234 * ```
235 *
236 * You can alternatively provide an in-line function with the `canActivate` signature:
237 *
238 * ```
239 * @NgModule({
240 * imports: [
241 * RouterModule.forRoot([
242 * {
243 * path: 'team/:id',
244 * component: TeamComponent,
245 * canActivate: ['canActivateTeam']
246 * }
247 * ])
248 * ],
249 * providers: [
250 * {
251 * provide: 'canActivateTeam',
252 * useValue: (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => true
253 * }
254 * ]
255 * })
256 * class AppModule {}
257 * ```
258 *
259 * @publicApi
260 */
261export declare interface CanActivate {
262 canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
263}
264
265/**
266 * @description
267 *
268 * Interface that a class can implement to be a guard deciding if a child route can be activated.
269 * If all guards return `true`, navigation continues. If any guard returns `false`,
270 * navigation is cancelled. If any guard returns a `UrlTree`, current navigation
271 * is cancelled and a new navigation begins to the `UrlTree` returned from the guard.
272 *
273 * The following example implements a `CanActivateChild` function that checks whether the
274 * current user has permission to activate the requested child route.
275 *
276 * ```
277 * class UserToken {}
278 * class Permissions {
279 * canActivate(user: UserToken, id: string): boolean {
280 * return true;
281 * }
282 * }
283 *
284 * @Injectable()
285 * class CanActivateTeam implements CanActivateChild {
286 * constructor(private permissions: Permissions, private currentUser: UserToken) {}
287 *
288 * canActivateChild(
289 * route: ActivatedRouteSnapshot,
290 * state: RouterStateSnapshot
291 * ): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean|UrlTree {
292 * return this.permissions.canActivate(this.currentUser, route.params.id);
293 * }
294 * }
295 * ```
296 *
297 * Here, the defined guard function is provided as part of the `Route` object
298 * in the router configuration:
299 *
300 * ```
301 * @NgModule({
302 * imports: [
303 * RouterModule.forRoot([
304 * {
305 * path: 'root',
306 * canActivateChild: [CanActivateTeam],
307 * children: [
308 * {
309 * path: 'team/:id',
310 * component: TeamComponent
311 * }
312 * ]
313 * }
314 * ])
315 * ],
316 * providers: [CanActivateTeam, UserToken, Permissions]
317 * })
318 * class AppModule {}
319 * ```
320 *
321 * You can alternatively provide an in-line function with the `canActivateChild` signature:
322 *
323 * ```
324 * @NgModule({
325 * imports: [
326 * RouterModule.forRoot([
327 * {
328 * path: 'root',
329 * canActivateChild: ['canActivateTeam'],
330 * children: [
331 * {
332 * path: 'team/:id',
333 * component: TeamComponent
334 * }
335 * ]
336 * }
337 * ])
338 * ],
339 * providers: [
340 * {
341 * provide: 'canActivateTeam',
342 * useValue: (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => true
343 * }
344 * ]
345 * })
346 * class AppModule {}
347 * ```
348 *
349 * @publicApi
350 */
351export declare interface CanActivateChild {
352 canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
353}
354
355/**
356 * @description
357 *
358 * Interface that a class can implement to be a guard deciding if a route can be deactivated.
359 * If all guards return `true`, navigation continues. If any guard returns `false`,
360 * navigation is cancelled. If any guard returns a `UrlTree`, current navigation
361 * is cancelled and a new navigation begins to the `UrlTree` returned from the guard.
362 *
363 * The following example implements a `CanDeactivate` function that checks whether the
364 * current user has permission to deactivate the requested route.
365 *
366 * ```
367 * class UserToken {}
368 * class Permissions {
369 * canDeactivate(user: UserToken, id: string): boolean {
370 * return true;
371 * }
372 * }
373 * ```
374 *
375 * Here, the defined guard function is provided as part of the `Route` object
376 * in the router configuration:
377 *
378 * ```
379 *
380 * @Injectable()
381 * class CanDeactivateTeam implements CanDeactivate<TeamComponent> {
382 * constructor(private permissions: Permissions, private currentUser: UserToken) {}
383 *
384 * canDeactivate(
385 * component: TeamComponent,
386 * currentRoute: ActivatedRouteSnapshot,
387 * currentState: RouterStateSnapshot,
388 * nextState: RouterStateSnapshot
389 * ): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean|UrlTree {
390 * return this.permissions.canDeactivate(this.currentUser, route.params.id);
391 * }
392 * }
393 *
394 * @NgModule({
395 * imports: [
396 * RouterModule.forRoot([
397 * {
398 * path: 'team/:id',
399 * component: TeamComponent,
400 * canDeactivate: [CanDeactivateTeam]
401 * }
402 * ])
403 * ],
404 * providers: [CanDeactivateTeam, UserToken, Permissions]
405 * })
406 * class AppModule {}
407 * ```
408 *
409 * You can alternatively provide an in-line function with the `canDeactivate` signature:
410 *
411 * ```
412 * @NgModule({
413 * imports: [
414 * RouterModule.forRoot([
415 * {
416 * path: 'team/:id',
417 * component: TeamComponent,
418 * canDeactivate: ['canDeactivateTeam']
419 * }
420 * ])
421 * ],
422 * providers: [
423 * {
424 * provide: 'canDeactivateTeam',
425 * useValue: (component: TeamComponent, currentRoute: ActivatedRouteSnapshot, currentState:
426 * RouterStateSnapshot, nextState: RouterStateSnapshot) => true
427 * }
428 * ]
429 * })
430 * class AppModule {}
431 * ```
432 *
433 * @publicApi
434 */
435export declare interface CanDeactivate<T> {
436 canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
437}
438
439/**
440 * @description
441 *
442 * Interface that a class can implement to be a guard deciding if children can be loaded.
443 * If all guards return `true`, navigation continues. If any guard returns `false`,
444 * navigation is cancelled. If any guard returns a `UrlTree`, current navigation
445 * is cancelled and a new navigation starts to the `UrlTree` returned from the guard.
446 *
447 * The following example implements a `CanLoad` function that decides whether the
448 * current user has permission to load requested child routes.
449 *
450 *
451 * ```
452 * class UserToken {}
453 * class Permissions {
454 * canLoadChildren(user: UserToken, id: string, segments: UrlSegment[]): boolean {
455 * return true;
456 * }
457 * }
458 *
459 * @Injectable()
460 * class CanLoadTeamSection implements CanLoad {
461 * constructor(private permissions: Permissions, private currentUser: UserToken) {}
462 *
463 * canLoad(route: Route, segments: UrlSegment[]): Observable<boolean>|Promise<boolean>|boolean {
464 * return this.permissions.canLoadChildren(this.currentUser, route, segments);
465 * }
466 * }
467 * ```
468 *
469 * Here, the defined guard function is provided as part of the `Route` object
470 * in the router configuration:
471 *
472 * ```
473 *
474 * @NgModule({
475 * imports: [
476 * RouterModule.forRoot([
477 * {
478 * path: 'team/:id',
479 * component: TeamComponent,
480 * loadChildren: 'team.js',
481 * canLoad: [CanLoadTeamSection]
482 * }
483 * ])
484 * ],
485 * providers: [CanLoadTeamSection, UserToken, Permissions]
486 * })
487 * class AppModule {}
488 * ```
489 *
490 * You can alternatively provide an in-line function with the `canLoad` signature:
491 *
492 * ```
493 * @NgModule({
494 * imports: [
495 * RouterModule.forRoot([
496 * {
497 * path: 'team/:id',
498 * component: TeamComponent,
499 * loadChildren: 'team.js',
500 * canLoad: ['canLoadTeamSection']
501 * }
502 * ])
503 * ],
504 * providers: [
505 * {
506 * provide: 'canLoadTeamSection',
507 * useValue: (route: Route, segments: UrlSegment[]) => true
508 * }
509 * ]
510 * })
511 * class AppModule {}
512 * ```
513 *
514 * @publicApi
515 */
516export declare interface CanLoad {
517 canLoad(route: Route, segments: UrlSegment[]): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
518}
519
520/**
521 * An event triggered at the end of the child-activation part
522 * of the Resolve phase of routing.
523 * @see `ChildActivationStart`
524 * @see `ResolveStart`
525 * @publicApi
526 */
527export declare class ChildActivationEnd {
528 /** @docsNotRequired */
529 snapshot: ActivatedRouteSnapshot;
530 constructor(
531 /** @docsNotRequired */
532 snapshot: ActivatedRouteSnapshot);
533 toString(): string;
534}
535
536/**
537 * An event triggered at the start of the child-activation
538 * part of the Resolve phase of routing.
539 * @see `ChildActivationEnd`
540 * @see `ResolveStart`
541 *
542 * @publicApi
543 */
544export declare class ChildActivationStart {
545 /** @docsNotRequired */
546 snapshot: ActivatedRouteSnapshot;
547 constructor(
548 /** @docsNotRequired */
549 snapshot: ActivatedRouteSnapshot);
550 toString(): string;
551}
552
553/**
554 * Store contextual information about the children (= nested) `RouterOutlet`
555 *
556 * @publicApi
557 */
558export declare class ChildrenOutletContexts {
559 private contexts;
560 /** Called when a `RouterOutlet` directive is instantiated */
561 onChildOutletCreated(childName: string, outlet: RouterOutlet): void;
562 /**
563 * Called when a `RouterOutlet` directive is destroyed.
564 * We need to keep the context as the outlet could be destroyed inside a NgIf and might be
565 * re-created later.
566 */
567 onChildOutletDestroyed(childName: string): void;
568 /**
569 * Called when the corresponding route is deactivated during navigation.
570 * Because the component get destroyed, all children outlet are destroyed.
571 */
572 onOutletDeactivated(): Map<string, OutletContext>;
573 onOutletReAttached(contexts: Map<string, OutletContext>): void;
574 getOrCreateContext(childName: string): OutletContext;
575 getContext(childName: string): OutletContext | null;
576}
577
578/**
579 * Converts a `Params` instance to a `ParamMap`.
580 * @param params The instance to convert.
581 * @returns The new map instance.
582 *
583 * @publicApi
584 */
585export declare function convertToParamMap(params: Params): ParamMap;
586
587/**
588 *
589 * Represents static data associated with a particular route.
590 *
591 * @see `Route#data`
592 *
593 * @publicApi
594 */
595export declare type Data = {
596 [name: string]: any;
597};
598
599/**
600 * @description
601 *
602 * A default implementation of the `UrlSerializer`.
603 *
604 * Example URLs:
605 *
606 * ```
607 * /inbox/33(popup:compose)
608 * /inbox/33;open=true/messages/44
609 * ```
610 *
611 * DefaultUrlSerializer uses parentheses to serialize secondary segments (e.g., popup:compose), the
612 * colon syntax to specify the outlet, and the ';parameter=value' syntax (e.g., open=true) to
613 * specify route specific parameters.
614 *
615 * @publicApi
616 */
617export declare class DefaultUrlSerializer implements UrlSerializer {
618 /** Parses a url into a `UrlTree` */
619 parse(url: string): UrlTree;
620 /** Converts a `UrlTree` into a url */
621 serialize(tree: UrlTree): string;
622}
623
624/**
625 * A string of the form `path/to/file#exportName` that acts as a URL for a set of routes to load.
626 *
627 * @see `loadChildrenCallback`
628 * @publicApi
629 * @deprecated The `string` form of `loadChildren` is deprecated in favor of the
630 * `LoadChildrenCallback` function which uses the ES dynamic `import()` expression.
631 * This offers a more natural and standards-based mechanism to dynamically
632 * load an ES module at runtime.
633 */
634export declare type DeprecatedLoadChildren = string;
635
636/**
637 * @description
638 *
639 * Represents the detached route tree.
640 *
641 * This is an opaque value the router will give to a custom route reuse strategy
642 * to store and retrieve later on.
643 *
644 * @publicApi
645 */
646export declare type DetachedRouteHandle = {};
647
648/**
649 * Error handler that is invoked when a navigation error occurs.
650 *
651 * If the handler returns a value, the navigation Promise is resolved with this value.
652 * If the handler throws an exception, the navigation Promise is rejected with
653 * the exception.
654 *
655 * @publicApi
656 */
657declare type ErrorHandler = (error: any) => any;
658
659/**
660 * Router events that allow you to track the lifecycle of the router.
661 *
662 * The events occur in the following sequence:
663 *
664 * * [NavigationStart](api/router/NavigationStart): Navigation starts.
665 * * [RouteConfigLoadStart](api/router/RouteConfigLoadStart): Before
666 * the router [lazy loads](/guide/router#lazy-loading) a route configuration.
667 * * [RouteConfigLoadEnd](api/router/RouteConfigLoadEnd): After a route has been lazy loaded.
668 * * [RoutesRecognized](api/router/RoutesRecognized): When the router parses the URL
669 * and the routes are recognized.
670 * * [GuardsCheckStart](api/router/GuardsCheckStart): When the router begins the *guards*
671 * phase of routing.
672 * * [ChildActivationStart](api/router/ChildActivationStart): When the router
673 * begins activating a route's children.
674 * * [ActivationStart](api/router/ActivationStart): When the router begins activating a route.
675 * * [GuardsCheckEnd](api/router/GuardsCheckEnd): When the router finishes the *guards*
676 * phase of routing successfully.
677 * * [ResolveStart](api/router/ResolveStart): When the router begins the *resolve*
678 * phase of routing.
679 * * [ResolveEnd](api/router/ResolveEnd): When the router finishes the *resolve*
680 * phase of routing successfuly.
681 * * [ChildActivationEnd](api/router/ChildActivationEnd): When the router finishes
682 * activating a route's children.
683 * * [ActivationEnd](api/router/ActivationStart): When the router finishes activating a route.
684 * * [NavigationEnd](api/router/NavigationEnd): When navigation ends successfully.
685 * * [NavigationCancel](api/router/NavigationCancel): When navigation is canceled.
686 * * [NavigationError](api/router/NavigationError): When navigation fails
687 * due to an unexpected error.
688 * * [Scroll](api/router/Scroll): When the user scrolls.
689 *
690 * @publicApi
691 */
692export declare type Event = RouterEvent | RouteConfigLoadStart | RouteConfigLoadEnd | ChildActivationStart | ChildActivationEnd | ActivationStart | ActivationEnd | Scroll;
693
694/**
695 * A set of configuration options for a router module, provided in the
696 * `forRoot()` method.
697 *
698 * @see `forRoot()`
699 *
700 *
701 * @publicApi
702 */
703export declare interface ExtraOptions {
704 /**
705 * When true, log all internal navigation events to the console.
706 * Use for debugging.
707 */
708 enableTracing?: boolean;
709 /**
710 * When true, enable the location strategy that uses the URL fragment
711 * instead of the history API.
712 */
713 useHash?: boolean;
714 /**
715 * One of `enabled` or `disabled`.
716 * When set to `enabled`, the initial navigation starts before the root component is created.
717 * The bootstrap is blocked until the initial navigation is complete. This value is required for
718 * [server-side rendering](guide/universal) to work.
719 * When set to `disabled`, the initial navigation is not performed.
720 * The location listener is set up before the root component gets created.
721 * Use if there is a reason to have more control over when the router
722 * starts its initial navigation due to some complex initialization logic.
723 *
724 * Legacy values are deprecated since v4 and should not be used for new applications:
725 *
726 * * `legacy_enabled` - Default for compatibility.
727 * The initial navigation starts after the root component has been created,
728 * but the bootstrap is not blocked until the initial navigation is complete.
729 * * `legacy_disabled` - The initial navigation is not performed.
730 * The location listener is set up after the root component gets created.
731 * * `true` - same as `legacy_enabled`.
732 * * `false` - same as `legacy_disabled`.
733 */
734 initialNavigation?: InitialNavigation;
735 /**
736 * A custom error handler for failed navigations.
737 * If the handler returns a value, the navigation Promise is resolved with this value.
738 * If the handler throws an exception, the navigation Promise is rejected with the exception.
739 *
740 */
741 errorHandler?: ErrorHandler;
742 /**
743 * Configures a preloading strategy.
744 * One of `PreloadAllModules` or `NoPreloading` (the default).
745 */
746 preloadingStrategy?: any;
747 /**
748 * Define what the router should do if it receives a navigation request to the current URL.
749 * Default is `ignore`, which causes the router ignores the navigation.
750 * This can disable features such as a "refresh" button.
751 * Use this option to configure the behavior when navigating to the
752 * current URL. Default is 'ignore'.
753 */
754 onSameUrlNavigation?: 'reload' | 'ignore';
755 /**
756 * Configures if the scroll position needs to be restored when navigating back.
757 *
758 * * 'disabled'- (Default) Does nothing. Scroll position is maintained on navigation.
759 * * 'top'- Sets the scroll position to x = 0, y = 0 on all navigation.
760 * * 'enabled'- Restores the previous scroll position on backward navigation, else sets the
761 * position to the anchor if one is provided, or sets the scroll position to [0, 0] (forward
762 * navigation). This option will be the default in the future.
763 *
764 * You can implement custom scroll restoration behavior by adapting the enabled behavior as
765 * in the following example.
766 *
767 * ```typescript
768 * class AppModule {
769 * constructor(router: Router, viewportScroller: ViewportScroller) {
770 * router.events.pipe(
771 * filter((e: Event): e is Scroll => e instanceof Scroll)
772 * ).subscribe(e => {
773 * if (e.position) {
774 * // backward navigation
775 * viewportScroller.scrollToPosition(e.position);
776 * } else if (e.anchor) {
777 * // anchor navigation
778 * viewportScroller.scrollToAnchor(e.anchor);
779 * } else {
780 * // forward navigation
781 * viewportScroller.scrollToPosition([0, 0]);
782 * }
783 * });
784 * }
785 * }
786 * ```
787 */
788 scrollPositionRestoration?: 'disabled' | 'enabled' | 'top';
789 /**
790 * When set to 'enabled', scrolls to the anchor element when the URL has a fragment.
791 * Anchor scrolling is disabled by default.
792 *
793 * Anchor scrolling does not happen on 'popstate'. Instead, we restore the position
794 * that we stored or scroll to the top.
795 */
796 anchorScrolling?: 'disabled' | 'enabled';
797 /**
798 * Configures the scroll offset the router will use when scrolling to an element.
799 *
800 * When given a tuple with x and y position value,
801 * the router uses that offset each time it scrolls.
802 * When given a function, the router invokes the function every time
803 * it restores scroll position.
804 */
805 scrollOffset?: [number, number] | (() => [number, number]);
806 /**
807 * Defines how the router merges parameters, data, and resolved data from parent to child
808 * routes. By default ('emptyOnly'), inherits parent parameters only for
809 * path-less or component-less routes.
810 * Set to 'always' to enable unconditional inheritance of parent parameters.
811 */
812 paramsInheritanceStrategy?: 'emptyOnly' | 'always';
813 /**
814 * A custom handler for malformed URI errors. The handler is invoked when `encodedURI` contains
815 * invalid character sequences.
816 * The default implementation is to redirect to the root URL, dropping
817 * any path or parameter information. The function takes three parameters:
818 *
819 * - `'URIError'` - Error thrown when parsing a bad URL.
820 * - `'UrlSerializer'` - UrlSerializer that’s configured with the router.
821 * - `'url'` - The malformed URL that caused the URIError
822 * */
823 malformedUriErrorHandler?: (error: URIError, urlSerializer: UrlSerializer, url: string) => UrlTree;
824 /**
825 * Defines when the router updates the browser URL. By default ('deferred'),
826 * update after successful navigation.
827 * Set to 'eager' if prefer to update the URL at the beginning of navigation.
828 * Updating the URL early allows you to handle a failure of navigation by
829 * showing an error message with the URL that failed.
830 */
831 urlUpdateStrategy?: 'deferred' | 'eager';
832 /**
833 * Enables a bug fix that corrects relative link resolution in components with empty paths.
834 * Example:
835 *
836 * ```
837 * const routes = [
838 * {
839 * path: '',
840 * component: ContainerComponent,
841 * children: [
842 * { path: 'a', component: AComponent },
843 * { path: 'b', component: BComponent },
844 * ]
845 * }
846 * ];
847 * ```
848 *
849 * From the `ContainerComponent`, this will not work:
850 *
851 * `<a [routerLink]="['./a']">Link to A</a>`
852 *
853 * However, this will work:
854 *
855 * `<a [routerLink]="['../a']">Link to A</a>`
856 *
857 * In other words, you're required to use `../` rather than `./`. This is currently the default
858 * behavior. Setting this option to `corrected` enables the fix.
859 */
860 relativeLinkResolution?: 'legacy' | 'corrected';
861}
862
863/**
864 * An event triggered at the end of the Guard phase of routing.
865 *
866 * @see `GuardsCheckStart`
867 *
868 * @publicApi
869 */
870export declare class GuardsCheckEnd extends RouterEvent {
871 /** @docsNotRequired */
872 urlAfterRedirects: string;
873 /** @docsNotRequired */
874 state: RouterStateSnapshot;
875 /** @docsNotRequired */
876 shouldActivate: boolean;
877 constructor(
878 /** @docsNotRequired */
879 id: number,
880 /** @docsNotRequired */
881 url: string,
882 /** @docsNotRequired */
883 urlAfterRedirects: string,
884 /** @docsNotRequired */
885 state: RouterStateSnapshot,
886 /** @docsNotRequired */
887 shouldActivate: boolean);
888 toString(): string;
889}
890
891/**
892 * An event triggered at the start of the Guard phase of routing.
893 *
894 * @see `GuardsCheckEnd`
895 *
896 * @publicApi
897 */
898export declare class GuardsCheckStart extends RouterEvent {
899 /** @docsNotRequired */
900 urlAfterRedirects: string;
901 /** @docsNotRequired */
902 state: RouterStateSnapshot;
903 constructor(
904 /** @docsNotRequired */
905 id: number,
906 /** @docsNotRequired */
907 url: string,
908 /** @docsNotRequired */
909 urlAfterRedirects: string,
910 /** @docsNotRequired */
911 state: RouterStateSnapshot);
912 toString(): string;
913}
914
915/**
916 * Allowed values in an `ExtraOptions` object that configure
917 * when the router performs the initial navigation operation.
918 *
919 * * 'enabled' - The initial navigation starts before the root component is created.
920 * The bootstrap is blocked until the initial navigation is complete. This value is required
921 * for [server-side rendering](guide/universal) to work.
922 * * 'disabled' - The initial navigation is not performed. The location listener is set up before
923 * the root component gets created. Use if there is a reason to have
924 * more control over when the router starts its initial navigation due to some complex
925 * initialization logic.
926 *
927 * The following values have been [deprecated](guide/releases#deprecation-practices) since v4,
928 * and should not be used for new applications.
929 *
930 * * 'legacy_enabled'- (Default, for compatibility.) The initial navigation starts after the root
931 * component has been created. The bootstrap is not blocked until the initial navigation is
932 * complete.
933 * * 'legacy_disabled'- The initial navigation is not performed. The location listener is set up
934 * after the root component gets created.
935 * * `true` - same as 'legacy_enabled'.
936 * * `false` - same as 'legacy_disabled'.
937 *
938 * The 'legacy_enabled' and 'legacy_disabled' should not be used for new applications.
939 *
940 * @see `forRoot()`
941 *
942 * @publicApi
943 */
944export declare type InitialNavigation = true | false | 'enabled' | 'disabled' | 'legacy_enabled' | 'legacy_disabled';
945
946/**
947 *
948 * A function that returns a set of routes to load.
949 *
950 * The string form of `LoadChildren` is deprecated (see `DeprecatedLoadChildren`). The function
951 * form (`LoadChildrenCallback`) should be used instead.
952 *
953 * @see `loadChildrenCallback`
954 * @publicApi
955 */
956export declare type LoadChildren = LoadChildrenCallback | DeprecatedLoadChildren;
957
958/**
959 *
960 * A function that is called to resolve a collection of lazy-loaded routes.
961 * Must be an arrow function of the following form:
962 * `() => import('...').then(mod => mod.MODULE)`
963 *
964 * For example:
965 *
966 * ```
967 * [{
968 * path: 'lazy',
969 * loadChildren: () => import('./lazy-route/lazy.module').then(mod => mod.LazyModule),
970 * }];
971 * ```
972 *
973 * @see [Route.loadChildren](api/router/Route#loadChildren)
974 * @publicApi
975 */
976export declare type LoadChildrenCallback = () => Type<any> | NgModuleFactory<any> | Observable<Type<any>> | Promise<NgModuleFactory<any> | Type<any> | any>;
977
978/**
979 * Information about a navigation operation.
980 * Retrieve the most recent navigation object with the
981 * [Router.getCurrentNavigation() method](api/router/Router#getcurrentnavigation) .
982 *
983 * * *id* : The unique identifier of the current navigation.
984 * * *initialUrl* : The target URL passed into the `Router#navigateByUrl()` call before navigation.
985 * This is the value before the router has parsed or applied redirects to it.
986 * * *extractedUrl* : The initial target URL after being parsed with `UrlSerializer.extract()`.
987 * * *finalUrl* : The extracted URL after redirects have been applied.
988 * This URL may not be available immediately, therefore this property can be `undefined`.
989 * It is guaranteed to be set after the `RoutesRecognized` event fires.
990 * * *trigger* : Identifies how this navigation was triggered.
991 * -- 'imperative'--Triggered by `router.navigateByUrl` or `router.navigate`.
992 * -- 'popstate'--Triggered by a popstate event.
993 * -- 'hashchange'--Triggered by a hashchange event.
994 * * *extras* : A `NavigationExtras` options object that controlled the strategy used for this
995 * navigation.
996 * * *previousNavigation* : The previously successful `Navigation` object. Only one previous
997 * navigation is available, therefore this previous `Navigation` object has a `null` value for its
998 * own `previousNavigation`.
999 *
1000 * @publicApi
1001 */
1002export declare type Navigation = {
1003 /**
1004 * The unique identifier of the current navigation.
1005 */
1006 id: number;
1007 /**
1008 * The target URL passed into the `Router#navigateByUrl()` call before navigation. This is
1009 * the value before the router has parsed or applied redirects to it.
1010 */
1011 initialUrl: string | UrlTree;
1012 /**
1013 * The initial target URL after being parsed with `UrlSerializer.extract()`.
1014 */
1015 extractedUrl: UrlTree;
1016 /**
1017 * The extracted URL after redirects have been applied.
1018 * This URL may not be available immediately, therefore this property can be `undefined`.
1019 * It is guaranteed to be set after the `RoutesRecognized` event fires.
1020 */
1021 finalUrl?: UrlTree;
1022 /**
1023 * Identifies how this navigation was triggered.
1024 *
1025 * * 'imperative'--Triggered by `router.navigateByUrl` or `router.navigate`.
1026 * * 'popstate'--Triggered by a popstate event.
1027 * * 'hashchange'--Triggered by a hashchange event.
1028 */
1029 trigger: 'imperative' | 'popstate' | 'hashchange';
1030 /**
1031 * Options that controlled the strategy used for this navigation.
1032 * See `NavigationExtras`.
1033 */
1034 extras: NavigationExtras;
1035 /**
1036 * The previously successful `Navigation` object. Only one previous navigation
1037 * is available, therefore this previous `Navigation` object has a `null` value
1038 * for its own `previousNavigation`.
1039 */
1040 previousNavigation: Navigation | null;
1041};
1042
1043/**
1044 * An event triggered when a navigation is canceled, directly or indirectly.
1045 * This can happen when a route guard
1046 * returns `false` or initiates a redirect by returning a `UrlTree`.
1047 *
1048 * @see `NavigationStart`
1049 * @see `NavigationEnd`
1050 * @see `NavigationError`
1051 *
1052 * @publicApi
1053 */
1054export declare class NavigationCancel extends RouterEvent {
1055 /** @docsNotRequired */
1056 reason: string;
1057 constructor(
1058 /** @docsNotRequired */
1059 id: number,
1060 /** @docsNotRequired */
1061 url: string,
1062 /** @docsNotRequired */
1063 reason: string);
1064 /** @docsNotRequired */
1065 toString(): string;
1066}
1067
1068/**
1069 * An event triggered when a navigation ends successfully.
1070 *
1071 * @see `NavigationStart`
1072 * @see `NavigationCancel`
1073 * @see `NavigationError`
1074 *
1075 * @publicApi
1076 */
1077export declare class NavigationEnd extends RouterEvent {
1078 /** @docsNotRequired */
1079 urlAfterRedirects: string;
1080 constructor(
1081 /** @docsNotRequired */
1082 id: number,
1083 /** @docsNotRequired */
1084 url: string,
1085 /** @docsNotRequired */
1086 urlAfterRedirects: string);
1087 /** @docsNotRequired */
1088 toString(): string;
1089}
1090
1091/**
1092 * An event triggered when a navigation fails due to an unexpected error.
1093 *
1094 * @see `NavigationStart`
1095 * @see `NavigationEnd`
1096 * @see `NavigationCancel`
1097 *
1098 * @publicApi
1099 */
1100export declare class NavigationError extends RouterEvent {
1101 /** @docsNotRequired */
1102 error: any;
1103 constructor(
1104 /** @docsNotRequired */
1105 id: number,
1106 /** @docsNotRequired */
1107 url: string,
1108 /** @docsNotRequired */
1109 error: any);
1110 /** @docsNotRequired */
1111 toString(): string;
1112}
1113
1114/**
1115 * @description
1116 *
1117 * Options that modify the `Router` navigation strategy.
1118 * Supply an object containing any of these properties to a `Router` navigation function to
1119 * control how the target URL should be constructed or interpreted.
1120 *
1121 * @see [Router.navigate() method](api/router/Router#navigate)
1122 * @see [Router.navigateByUrl() method](api/router/Router#navigatebyurl)
1123 * @see [Router.createUrlTree() method](api/router/Router#createurltree)
1124 * @see [Routing and Navigation guide](guide/router)
1125 *
1126 * @publicApi
1127 */
1128export declare interface NavigationExtras {
1129 /**
1130 * Specifies a root URI to use for relative navigation.
1131 *
1132 * For example, consider the following route configuration where the parent route
1133 * has two children.
1134 *
1135 * ```
1136 * [{
1137 * path: 'parent',
1138 * component: ParentComponent,
1139 * children: [{
1140 * path: 'list',
1141 * component: ListComponent
1142 * },{
1143 * path: 'child',
1144 * component: ChildComponent
1145 * }]
1146 * }]
1147 * ```
1148 *
1149 * The following `go()` function navigates to the `list` route by
1150 * interpreting the destination URI as relative to the activated `child` route
1151 *
1152 * ```
1153 * @Component({...})
1154 * class ChildComponent {
1155 * constructor(private router: Router, private route: ActivatedRoute) {}
1156 *
1157 * go() {
1158 * this.router.navigate(['../list'], { relativeTo: this.route });
1159 * }
1160 * }
1161 * ```
1162 */
1163 relativeTo?: ActivatedRoute | null;
1164 /**
1165 * Sets query parameters to the URL.
1166 *
1167 * ```
1168 * // Navigate to /results?page=1
1169 * this.router.navigate(['/results'], { queryParams: { page: 1 } });
1170 * ```
1171 */
1172 queryParams?: Params | null;
1173 /**
1174 * Sets the hash fragment for the URL.
1175 *
1176 * ```
1177 * // Navigate to /results#top
1178 * this.router.navigate(['/results'], { fragment: 'top' });
1179 * ```
1180 */
1181 fragment?: string;
1182 /**
1183 * **DEPRECATED**: Use `queryParamsHandling: "preserve"` instead to preserve
1184 * query parameters for the next navigation.
1185 *
1186 * @deprecated since v4
1187 */
1188 preserveQueryParams?: boolean;
1189 /**
1190 * How to handle query parameters in the router link for the next navigation.
1191 * One of:
1192 * * `preserve` : Preserve current parameters.
1193 * * `merge` : Merge new with current parameters.
1194 *
1195 * The "preserve" option discards any new query params:
1196 * ```
1197 * // from /view1?page=1 to/view2?page=1
1198 * this.router.navigate(['/view2'], { queryParams: { page: 2 }, queryParamsHandling: "preserve"
1199 * });
1200 * ```
1201 * The "merge" option appends new query params to the params from the current URL:
1202 * ```
1203 * // from /view1?page=1 to/view2?page=1&otherKey=2
1204 * this.router.navigate(['/view2'], { queryParams: { otherKey: 2 }, queryParamsHandling: "merge"
1205 * });
1206 * ```
1207 * In case of a key collision between current parameters and those in the `queryParams` object,
1208 * the new value is used.
1209 *
1210 */
1211 queryParamsHandling?: QueryParamsHandling | null;
1212 /**
1213 * When true, preserves the URL fragment for the next navigation
1214 *
1215 * ```
1216 * // Preserve fragment from /results#top to /view#top
1217 * this.router.navigate(['/view'], { preserveFragment: true });
1218 * ```
1219 */
1220 preserveFragment?: boolean;
1221 /**
1222 * When true, navigates without pushing a new state into history.
1223 *
1224 * ```
1225 * // Navigate silently to /view
1226 * this.router.navigate(['/view'], { skipLocationChange: true });
1227 * ```
1228 */
1229 skipLocationChange?: boolean;
1230 /**
1231 * When true, navigates while replacing the current state in history.
1232 *
1233 * ```
1234 * // Navigate to /view
1235 * this.router.navigate(['/view'], { replaceUrl: true });
1236 * ```
1237 */
1238 replaceUrl?: boolean;
1239 /**
1240 * Developer-defined state that can be passed to any navigation.
1241 * Access this value through the `Navigation.extras` object
1242 * returned from the [Router.getCurrentNavigation()
1243 * method](api/router/Router#getcurrentnavigation) while a navigation is executing.
1244 *
1245 * After a navigation completes, the router writes an object containing this
1246 * value together with a `navigationId` to `history.state`.
1247 * The value is written when `location.go()` or `location.replaceState()`
1248 * is called before activating this route.
1249 *
1250 * Note that `history.state` does not pass an object equality test because
1251 * the router adds the `navigationId` on each navigation.
1252 *
1253 */
1254 state?: {
1255 [k: string]: any;
1256 };
1257}
1258
1259/**
1260 * An event triggered when a navigation starts.
1261 *
1262 * @publicApi
1263 */
1264export declare class NavigationStart extends RouterEvent {
1265 /**
1266 * Identifies the call or event that triggered the navigation.
1267 * An `imperative` trigger is a call to `router.navigateByUrl()` or `router.navigate()`.
1268 *
1269 * @see `NavigationEnd`
1270 * @see `NavigationCancel`
1271 * @see `NavigationError`
1272 */
1273 navigationTrigger?: 'imperative' | 'popstate' | 'hashchange';
1274 /**
1275 * The navigation state that was previously supplied to the `pushState` call,
1276 * when the navigation is triggered by a `popstate` event. Otherwise null.
1277 *
1278 * The state object is defined by `NavigationExtras`, and contains any
1279 * developer-defined state value, as well as a unique ID that
1280 * the router assigns to every router transition/navigation.
1281 *
1282 * From the perspective of the router, the router never "goes back".
1283 * When the user clicks on the back button in the browser,
1284 * a new navigation ID is created.
1285 *
1286 * Use the ID in this previous-state object to differentiate between a newly created
1287 * state and one returned to by a `popstate` event, so that you can restore some
1288 * remembered state, such as scroll position.
1289 *
1290 */
1291 restoredState?: {
1292 [k: string]: any;
1293 navigationId: number;
1294 } | null;
1295 constructor(
1296 /** @docsNotRequired */
1297 id: number,
1298 /** @docsNotRequired */
1299 url: string,
1300 /** @docsNotRequired */
1301 navigationTrigger?: 'imperative' | 'popstate' | 'hashchange',
1302 /** @docsNotRequired */
1303 restoredState?: {
1304 [k: string]: any;
1305 navigationId: number;
1306 } | null);
1307 /** @docsNotRequired */
1308 toString(): string;
1309}
1310
1311/**
1312 * @description
1313 *
1314 * Provides a preloading strategy that does not preload any modules.
1315 *
1316 * This strategy is enabled by default.
1317 *
1318 * @publicApi
1319 */
1320export declare class NoPreloading implements PreloadingStrategy {
1321 preload(route: Route, fn: () => Observable<any>): Observable<any>;
1322}
1323
1324/**
1325 * Store contextual information about a `RouterOutlet`
1326 *
1327 * @publicApi
1328 */
1329export declare class OutletContext {
1330 outlet: RouterOutlet | null;
1331 route: ActivatedRoute | null;
1332 resolver: ComponentFactoryResolver | null;
1333 children: ChildrenOutletContexts;
1334 attachRef: ComponentRef<any> | null;
1335}
1336
1337/**
1338 * A map that provides access to the required and optional parameters
1339 * specific to a route.
1340 * The map supports retrieving a single value with `get()`
1341 * or multiple values with `getAll()`.
1342 *
1343 * @see [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
1344 *
1345 * @publicApi
1346 */
1347export declare interface ParamMap {
1348 /**
1349 * Reports whether the map contains a given parameter.
1350 * @param name The parameter name.
1351 * @returns True if the map contains the given parameter, false otherwise.
1352 */
1353 has(name: string): boolean;
1354 /**
1355 * Retrieves a single value for a parameter.
1356 * @param name The parameter name.
1357 * @return The parameter's single value,
1358 * or the first value if the parameter has multiple values,
1359 * or `null` when there is no such parameter.
1360 */
1361 get(name: string): string | null;
1362 /**
1363 * Retrieves multiple values for a parameter.
1364 * @param name The parameter name.
1365 * @return An array containing one or more values,
1366 * or an empty array if there is no such parameter.
1367 *
1368 */
1369 getAll(name: string): string[];
1370 /** Names of the parameters in the map. */
1371 readonly keys: string[];
1372}
1373
1374/**
1375 * A collection of matrix and query URL parameters.
1376 * @see `convertToParamMap()`
1377 * @see `ParamMap`
1378 *
1379 * @publicApi
1380 */
1381export declare type Params = {
1382 [key: string]: any;
1383};
1384
1385/**
1386 * @description
1387 *
1388 * Provides a preloading strategy that preloads all modules as quickly as possible.
1389 *
1390 * ```
1391 * RouteModule.forRoot(ROUTES, {preloadingStrategy: PreloadAllModules})
1392 * ```
1393 *
1394 * @publicApi
1395 */
1396export declare class PreloadAllModules implements PreloadingStrategy {
1397 preload(route: Route, fn: () => Observable<any>): Observable<any>;
1398}
1399
1400/**
1401 * @description
1402 *
1403 * Provides a preloading strategy.
1404 *
1405 * @publicApi
1406 */
1407export declare abstract class PreloadingStrategy {
1408 abstract preload(route: Route, fn: () => Observable<any>): Observable<any>;
1409}
1410
1411/**
1412 * The primary routing outlet.
1413 *
1414 * @publicApi
1415 */
1416export declare const PRIMARY_OUTLET = "primary";
1417
1418/**
1419 * Registers a [DI provider](guide/glossary#provider) for a set of routes.
1420 * @param routes The route configuration to provide.
1421 *
1422 * @usageNotes
1423 *
1424 * ```
1425 * @NgModule({
1426 * imports: [RouterModule.forChild(ROUTES)],
1427 * providers: [provideRoutes(EXTRA_ROUTES)]
1428 * })
1429 * class MyNgModule {}
1430 * ```
1431 *
1432 * @publicApi
1433 */
1434export declare function provideRoutes(routes: Routes): any;
1435
1436/**
1437 *
1438 * How to handle query parameters in a router link.
1439 * One of:
1440 * - `merge` : Merge new with current parameters.
1441 * - `preserve` : Preserve current parameters.
1442 *
1443 * @see `NavigationExtras#queryParamsHandling`
1444 * @see `RouterLink`
1445 * @publicApi
1446 */
1447export declare type QueryParamsHandling = 'merge' | 'preserve' | '';
1448
1449/**
1450 * @description
1451 *
1452 * Interface that classes can implement to be a data provider.
1453 * A data provider class can be used with the router to resolve data during navigation.
1454 * The interface defines a `resolve()` method that is invoked when the navigation starts.
1455 * The router waits for the data to be resolved before the route is finally activated.
1456 *
1457 * The following example implements a `resolve()` method that retrieves the data
1458 * needed to activate the requested route.
1459 *
1460 * ```
1461 * @Injectable({ providedIn: 'root' })
1462 * export class HeroResolver implements Resolve<Hero> {
1463 * constructor(private service: HeroService) {}
1464 *
1465 * resolve(
1466 * route: ActivatedRouteSnapshot,
1467 * state: RouterStateSnapshot
1468 * ): Observable<any>|Promise<any>|any {
1469 * return this.service.getHero(route.paramMap.get('id'));
1470 * }
1471 * }
1472 * ```
1473 *
1474 * Here, the defined `resolve()` function is provided as part of the `Route` object
1475 * in the router configuration:
1476 *
1477 * ```
1478
1479 * @NgModule({
1480 * imports: [
1481 * RouterModule.forRoot([
1482 * {
1483 * path: 'detail/:id',
1484 * component: HeroDetailComponent,
1485 * resolve: {
1486 * hero: HeroResolver
1487 * }
1488 * }
1489 * ])
1490 * ],
1491 * exports: [RouterModule]
1492 * })
1493 * export class AppRoutingModule {}
1494 * ```
1495 *
1496 * You can alternatively provide an in-line function with the `resolve()` signature:
1497 *
1498 * ```
1499 * export const myHero: Hero = {
1500 * // ...
1501 * }
1502 *
1503 * @NgModule({
1504 * imports: [
1505 * RouterModule.forRoot([
1506 * {
1507 * path: 'detail/:id',
1508 * component: HeroComponent,
1509 * resolve: {
1510 * hero: 'heroResolver'
1511 * }
1512 * }
1513 * ])
1514 * ],
1515 * providers: [
1516 * {
1517 * provide: 'heroResolver',
1518 * useValue: (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => myHero
1519 * }
1520 * ]
1521 * })
1522 * export class AppModule {}
1523 * ```
1524 *
1525 * @usageNotes
1526 *
1527 * When both guard and resolvers are specified, the resolvers are not executed until
1528 * all guards have run and succeeded.
1529 * For example, consider the following route configuration:
1530 *
1531 * ```
1532 * {
1533 * path: 'base'
1534 * canActivate: [BaseGuard],
1535 * resolve: {data: BaseDataResolver}
1536 * children: [
1537 * {
1538 * path: 'child',
1539 * guards: [ChildGuard],
1540 * component: ChildComponent,
1541 * resolve: {childData: ChildDataResolver}
1542 * }
1543 * ]
1544 * }
1545 * ```
1546 * The order of execution is: BaseGuard, ChildGuard, BaseDataResolver, ChildDataResolver.
1547 *
1548 * @publicApi
1549 */
1550export declare interface Resolve<T> {
1551 resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<T> | Promise<T> | T;
1552}
1553
1554/**
1555 *
1556 * Represents the resolved data associated with a particular route.
1557 *
1558 * @see `Route#resolve`.
1559 *
1560 * @publicApi
1561 */
1562export declare type ResolveData = {
1563 [name: string]: any;
1564};
1565
1566/**
1567 * An event triggered at the end of the Resolve phase of routing.
1568 * @see `ResolveStart`.
1569 *
1570 * @publicApi
1571 */
1572export declare class ResolveEnd extends RouterEvent {
1573 /** @docsNotRequired */
1574 urlAfterRedirects: string;
1575 /** @docsNotRequired */
1576 state: RouterStateSnapshot;
1577 constructor(
1578 /** @docsNotRequired */
1579 id: number,
1580 /** @docsNotRequired */
1581 url: string,
1582 /** @docsNotRequired */
1583 urlAfterRedirects: string,
1584 /** @docsNotRequired */
1585 state: RouterStateSnapshot);
1586 toString(): string;
1587}
1588
1589/**
1590 * An event triggered at the the start of the Resolve phase of routing.
1591 *
1592 * Runs in the "resolve" phase whether or not there is anything to resolve.
1593 * In future, may change to only run when there are things to be resolved.
1594 *
1595 * @see `ResolveEnd`
1596 *
1597 * @publicApi
1598 */
1599export declare class ResolveStart extends RouterEvent {
1600 /** @docsNotRequired */
1601 urlAfterRedirects: string;
1602 /** @docsNotRequired */
1603 state: RouterStateSnapshot;
1604 constructor(
1605 /** @docsNotRequired */
1606 id: number,
1607 /** @docsNotRequired */
1608 url: string,
1609 /** @docsNotRequired */
1610 urlAfterRedirects: string,
1611 /** @docsNotRequired */
1612 state: RouterStateSnapshot);
1613 toString(): string;
1614}
1615
1616/**
1617 * A configuration object that defines a single route.
1618 * A set of routes are collected in a `Routes` array to define a `Router` configuration.
1619 * The router attempts to match segments of a given URL against each route,
1620 * using the configuration options defined in this object.
1621 *
1622 * Supports static, parameterized, redirect, and wildcard routes, as well as
1623 * custom route data and resolve methods.
1624 *
1625 * For detailed usage information, see the [Routing Guide](guide/router).
1626 *
1627 * @usageNotes
1628 *
1629 * ### Simple Configuration
1630 *
1631 * The following route specifies that when navigating to, for example,
1632 * `/team/11/user/bob`, the router creates the 'Team' component
1633 * with the 'User' child component in it.
1634 *
1635 * ```
1636 * [{
1637 * path: 'team/:id',
1638 * component: Team,
1639 * children: [{
1640 * path: 'user/:name',
1641 * component: User
1642 * }]
1643 * }]
1644 * ```
1645 *
1646 * ### Multiple Outlets
1647 *
1648 * The following route creates sibling components with multiple outlets.
1649 * When navigating to `/team/11(aux:chat/jim)`, the router creates the 'Team' component next to
1650 * the 'Chat' component. The 'Chat' component is placed into the 'aux' outlet.
1651 *
1652 * ```
1653 * [{
1654 * path: 'team/:id',
1655 * component: Team
1656 * }, {
1657 * path: 'chat/:user',
1658 * component: Chat
1659 * outlet: 'aux'
1660 * }]
1661 * ```
1662 *
1663 * ### Wild Cards
1664 *
1665 * The following route uses wild-card notation to specify a component
1666 * that is always instantiated regardless of where you navigate to.
1667 *
1668 * ```
1669 * [{
1670 * path: '**',
1671 * component: WildcardComponent
1672 * }]
1673 * ```
1674 *
1675 * ### Redirects
1676 *
1677 * The following route uses the `redirectTo` property to ignore a segment of
1678 * a given URL when looking for a child path.
1679 *
1680 * When navigating to '/team/11/legacy/user/jim', the router changes the URL segment
1681 * '/team/11/legacy/user/jim' to '/team/11/user/jim', and then instantiates
1682 * the Team component with the User child component in it.
1683 *
1684 * ```
1685 * [{
1686 * path: 'team/:id',
1687 * component: Team,
1688 * children: [{
1689 * path: 'legacy/user/:name',
1690 * redirectTo: 'user/:name'
1691 * }, {
1692 * path: 'user/:name',
1693 * component: User
1694 * }]
1695 * }]
1696 * ```
1697 *
1698 * The redirect path can be relative, as shown in this example, or absolute.
1699 * If we change the `redirectTo` value in the example to the absolute URL segment '/user/:name',
1700 * the result URL is also absolute, '/user/jim'.
1701
1702 * ### Empty Path
1703 *
1704 * Empty-path route configurations can be used to instantiate components that do not 'consume'
1705 * any URL segments.
1706 *
1707 * In the following configuration, when navigating to
1708 * `/team/11`, the router instantiates the 'AllUsers' component.
1709 *
1710 * ```
1711 * [{
1712 * path: 'team/:id',
1713 * component: Team,
1714 * children: [{
1715 * path: '',
1716 * component: AllUsers
1717 * }, {
1718 * path: 'user/:name',
1719 * component: User
1720 * }]
1721 * }]
1722 * ```
1723 *
1724 * Empty-path routes can have children. In the following example, when navigating
1725 * to `/team/11/user/jim`, the router instantiates the wrapper component with
1726 * the user component in it.
1727 *
1728 * Note that an empty path route inherits its parent's parameters and data.
1729 *
1730 * ```
1731 * [{
1732 * path: 'team/:id',
1733 * component: Team,
1734 * children: [{
1735 * path: '',
1736 * component: WrapperCmp,
1737 * children: [{
1738 * path: 'user/:name',
1739 * component: User
1740 * }]
1741 * }]
1742 * }]
1743 * ```
1744 *
1745 * ### Matching Strategy
1746 *
1747 * The default path-match strategy is 'prefix', which means that the router
1748 * checks URL elements from the left to see if the URL matches a specified path.
1749 * For example, '/team/11/user' matches 'team/:id'.
1750 *
1751 * ```
1752 * [{
1753 * path: '',
1754 * pathMatch: 'prefix', //default
1755 * redirectTo: 'main'
1756 * }, {
1757 * path: 'main',
1758 * component: Main
1759 * }]
1760 * ```
1761 *
1762 * You can specify the path-match strategy 'full' to make sure that the path
1763 * covers the whole unconsumed URL. It is important to do this when redirecting
1764 * empty-path routes. Otherwise, because an empty path is a prefix of any URL,
1765 * the router would apply the redirect even when navigating to the redirect destination,
1766 * creating an endless loop.
1767 *
1768 * In the following example, supplying the 'full' `pathMatch` strategy ensures
1769 * that the router applies the redirect if and only if navigating to '/'.
1770 *
1771 * ```
1772 * [{
1773 * path: '',
1774 * pathMatch: 'full',
1775 * redirectTo: 'main'
1776 * }, {
1777 * path: 'main',
1778 * component: Main
1779 * }]
1780 * ```
1781 *
1782 * ### Componentless Routes
1783 *
1784 * You can share parameters between sibling components.
1785 * For example, suppose that two sibling components should go next to each other,
1786 * and both of them require an ID parameter. You can accomplish this using a route
1787 * that does not specify a component at the top level.
1788 *
1789 * In the following example, 'MainChild' and 'AuxChild' are siblings.
1790 * When navigating to 'parent/10/(a//aux:b)', the route instantiates
1791 * the main child and aux child components next to each other.
1792 * For this to work, the application component must have the primary and aux outlets defined.
1793 *
1794 * ```
1795 * [{
1796 * path: 'parent/:id',
1797 * children: [
1798 * { path: 'a', component: MainChild },
1799 * { path: 'b', component: AuxChild, outlet: 'aux' }
1800 * ]
1801 * }]
1802 * ```
1803 *
1804 * The router merges the parameters, data, and resolve of the componentless
1805 * parent into the parameters, data, and resolve of the children.
1806 *
1807 * This is especially useful when child components are defined
1808 * with an empty path string, as in the following example.
1809 * With this configuration, navigating to '/parent/10' creates
1810 * the main child and aux components.
1811 *
1812 * ```
1813 * [{
1814 * path: 'parent/:id',
1815 * children: [
1816 * { path: '', component: MainChild },
1817 * { path: '', component: AuxChild, outlet: 'aux' }
1818 * ]
1819 * }]
1820 * ```
1821 *
1822 * ### Lazy Loading
1823 *
1824 * Lazy loading speeds up application load time by splitting the application
1825 * into multiple bundles and loading them on demand.
1826 * To use lazy loading, provide the `loadChildren` property in the `Route` object,
1827 * instead of the `children` property.
1828 *
1829 * Given the following example route, the router will lazy load
1830 * the associated module on demand using the browser native import system.
1831 *
1832 * ```
1833 * [{
1834 * path: 'lazy',
1835 * loadChildren: () => import('./lazy-route/lazy.module').then(mod => mod.LazyModule),
1836 * }];
1837 * ```
1838 *
1839 * @publicApi
1840 */
1841export declare interface Route {
1842 /**
1843 * The path to match against. Cannot be used together with a custom `matcher` function.
1844 * A URL string that uses router matching notation.
1845 * Can be a wild card (`**`) that matches any URL (see Usage Notes below).
1846 * Default is "/" (the root path).
1847 *
1848 */
1849 path?: string;
1850 /**
1851 * The path-matching strategy, one of 'prefix' or 'full'.
1852 * Default is 'prefix'.
1853 *
1854 * By default, the router checks URL elements from the left to see if the URL
1855 * matches a given path, and stops when there is a match. For example,
1856 * '/team/11/user' matches 'team/:id'.
1857 *
1858 * The path-match strategy 'full' matches against the entire URL.
1859 * It is important to do this when redirecting empty-path routes.
1860 * Otherwise, because an empty path is a prefix of any URL,
1861 * the router would apply the redirect even when navigating
1862 * to the redirect destination, creating an endless loop.
1863 *
1864 */
1865 pathMatch?: string;
1866 /**
1867 * A custom URL-matching function. Cannot be used together with `path`.
1868 */
1869 matcher?: UrlMatcher;
1870 /**
1871 * The component to instantiate when the path matches.
1872 * Can be empty if child routes specify components.
1873 */
1874 component?: Type<any>;
1875 /**
1876 * A URL to redirect to when the path matches.
1877 * Absolute if the URL begins with a slash (/), otherwise relative to the path URL.
1878 * When not present, router does not redirect.
1879 */
1880 redirectTo?: string;
1881 /**
1882 * Name of a `RouterOutlet` object where the component can be placed
1883 * when the path matches.
1884 */
1885 outlet?: string;
1886 /**
1887 * An array of dependency-injection tokens used to look up `CanActivate()`
1888 * handlers, in order to determine if the current user is allowed to
1889 * activate the component. By default, any user can activate.
1890 */
1891 canActivate?: any[];
1892 /**
1893 * An array of DI tokens used to look up `CanActivateChild()` handlers,
1894 * in order to determine if the current user is allowed to activate
1895 * a child of the component. By default, any user can activate a child.
1896 */
1897 canActivateChild?: any[];
1898 /**
1899 * An array of DI tokens used to look up `CanDeactivate()`
1900 * handlers, in order to determine if the current user is allowed to
1901 * deactivate the component. By default, any user can deactivate.
1902 *
1903 */
1904 canDeactivate?: any[];
1905 /**
1906 * An array of DI tokens used to look up `CanLoad()`
1907 * handlers, in order to determine if the current user is allowed to
1908 * load the component. By default, any user can load.
1909 */
1910 canLoad?: any[];
1911 /**
1912 * Additional developer-defined data provided to the component via
1913 * `ActivatedRoute`. By default, no additional data is passed.
1914 */
1915 data?: Data;
1916 /**
1917 * A map of DI tokens used to look up data resolvers. See `Resolve`.
1918 */
1919 resolve?: ResolveData;
1920 /**
1921 * An array of child `Route` objects that specifies a nested route
1922 * configuration.
1923 */
1924 children?: Routes;
1925 /**
1926 * An object specifying lazy-loaded child routes.
1927 */
1928 loadChildren?: LoadChildren;
1929 /**
1930 * Defines when guards and resolvers will be run. One of
1931 * - `paramsOrQueryParamsChange` : Run when query parameters change.
1932 * - `always` : Run on every execution.
1933 * By default, guards and resolvers run only when the matrix
1934 * parameters of the route change.
1935 */
1936 runGuardsAndResolvers?: RunGuardsAndResolvers;
1937}
1938
1939/**
1940 * An event triggered when a route has been lazy loaded.
1941 *
1942 * @see `RouteConfigLoadStart`
1943 *
1944 * @publicApi
1945 */
1946export declare class RouteConfigLoadEnd {
1947 /** @docsNotRequired */
1948 route: Route;
1949 constructor(
1950 /** @docsNotRequired */
1951 route: Route);
1952 toString(): string;
1953}
1954
1955/**
1956 * An event triggered before lazy loading a route configuration.
1957 *
1958 * @see `RouteConfigLoadEnd`
1959 *
1960 * @publicApi
1961 */
1962export declare class RouteConfigLoadStart {
1963 /** @docsNotRequired */
1964 route: Route;
1965 constructor(
1966 /** @docsNotRequired */
1967 route: Route);
1968 toString(): string;
1969}
1970
1971/**
1972 * @description
1973 *
1974 * A service that provides navigation among views and URL manipulation capabilities.
1975 *
1976 * @see `Route`.
1977 * @see [Routing and Navigation Guide](guide/router).
1978 *
1979 * @ngModule RouterModule
1980 *
1981 * @publicApi
1982 */
1983export declare class Router {
1984 private rootComponentType;
1985 private urlSerializer;
1986 private rootContexts;
1987 private location;
1988 config: Routes;
1989 private currentUrlTree;
1990 private rawUrlTree;
1991 private browserUrlTree;
1992 private readonly transitions;
1993 private navigations;
1994 private lastSuccessfulNavigation;
1995 private currentNavigation;
1996 private locationSubscription;
1997 private navigationId;
1998 private configLoader;
1999 private ngModule;
2000 private console;
2001 private isNgZoneEnabled;
2002 /**
2003 * An event stream for routing events in this NgModule.
2004 */
2005 readonly events: Observable<Event>;
2006 /**
2007 * The current state of routing in this NgModule.
2008 */
2009 readonly routerState: RouterState;
2010 /**
2011 * A handler for navigation errors in this NgModule.
2012 */
2013 errorHandler: ErrorHandler;
2014 /**
2015 * A handler for errors thrown by `Router.parseUrl(url)`
2016 * when `url` contains an invalid character.
2017 * The most common case is a `%` sign
2018 * that's not encoded and is not part of a percent encoded sequence.
2019 */
2020 malformedUriErrorHandler: (error: URIError, urlSerializer: UrlSerializer, url: string) => UrlTree;
2021 /**
2022 * True if at least one navigation event has occurred,
2023 * false otherwise.
2024 */
2025 navigated: boolean;
2026 private lastSuccessfulId;
2027 /**
2028 * A strategy for extracting and merging URLs.
2029 * Used for AngularJS to Angular migrations.
2030 */
2031 urlHandlingStrategy: UrlHandlingStrategy;
2032 /**
2033 * A strategy for re-using routes.
2034 */
2035 routeReuseStrategy: RouteReuseStrategy;
2036 /**
2037 * How to handle a navigation request to the current URL. One of:
2038 * - `'ignore'` : The router ignores the request.
2039 * - `'reload'` : The router reloads the URL. Use to implement a "refresh" feature.
2040 */
2041 onSameUrlNavigation: 'reload' | 'ignore';
2042 /**
2043 * How to merge parameters, data, and resolved data from parent to child
2044 * routes. One of:
2045 *
2046 * - `'emptyOnly'` : Inherit parent parameters, data, and resolved data
2047 * for path-less or component-less routes.
2048 * - `'always'` : Inherit parent parameters, data, and resolved data
2049 * for all child routes.
2050 */
2051 paramsInheritanceStrategy: 'emptyOnly' | 'always';
2052 /**
2053 * Determines when the router updates the browser URL.
2054 * By default (`"deferred"`), updates the browser URL after navigation has finished.
2055 * Set to `'eager'` to update the browser URL at the beginning of navigation.
2056 * You can choose to update early so that, if navigation fails,
2057 * you can show an error message with the URL that failed.
2058 */
2059 urlUpdateStrategy: 'deferred' | 'eager';
2060 /**
2061 * Enables a bug fix that corrects relative link resolution in components with empty paths.
2062 * @see `RouterModule`
2063 */
2064 relativeLinkResolution: 'legacy' | 'corrected';
2065 /**
2066 * Creates the router service.
2067 */
2068 constructor(rootComponentType: Type<any> | null, urlSerializer: UrlSerializer, rootContexts: ChildrenOutletContexts, location: Location, injector: Injector, loader: NgModuleFactoryLoader, compiler: Compiler, config: Routes);
2069 private setupNavigations;
2070 private getTransition;
2071 private setTransition;
2072 /**
2073 * Sets up the location change listener and performs the initial navigation.
2074 */
2075 initialNavigation(): void;
2076 /**
2077 * Sets up the location change listener.
2078 */
2079 setUpLocationChangeListener(): void;
2080 /** The current URL. */
2081 get url(): string;
2082 /** The current Navigation object if one exists */
2083 getCurrentNavigation(): Navigation | null;
2084 /**
2085 * Resets the route configuration used for navigation and generating links.
2086 *
2087 * @param config The route array for the new configuration.
2088 *
2089 * @usageNotes
2090 *
2091 * ```
2092 * router.resetConfig([
2093 * { path: 'team/:id', component: TeamCmp, children: [
2094 * { path: 'simple', component: SimpleCmp },
2095 * { path: 'user/:name', component: UserCmp }
2096 * ]}
2097 * ]);
2098 * ```
2099 */
2100 resetConfig(config: Routes): void;
2101 /** @docsNotRequired */
2102 ngOnDestroy(): void;
2103 /** Disposes of the router. */
2104 dispose(): void;
2105 /**
2106 * Appends URL segments to the current URL tree to create a new URL tree.
2107 *
2108 * @param commands An array of URL fragments with which to construct the new URL tree.
2109 * If the path is static, can be the literal URL string. For a dynamic path, pass an array of path
2110 * segments, followed by the parameters for each segment.
2111 * The fragments are applied to the current URL tree or the one provided in the `relativeTo`
2112 * property of the options object, if supplied.
2113 * @param navigationExtras Options that control the navigation strategy. This function
2114 * only uses properties in `NavigationExtras` that would change the provided URL.
2115 * @returns The new URL tree.
2116 *
2117 * @usageNotes
2118 *
2119 * ```
2120 * // create /team/33/user/11
2121 * router.createUrlTree(['/team', 33, 'user', 11]);
2122 *
2123 * // create /team/33;expand=true/user/11
2124 * router.createUrlTree(['/team', 33, {expand: true}, 'user', 11]);
2125 *
2126 * // you can collapse static segments like this (this works only with the first passed-in value):
2127 * router.createUrlTree(['/team/33/user', userId]);
2128 *
2129 * // If the first segment can contain slashes, and you do not want the router to split it,
2130 * // you can do the following:
2131 * router.createUrlTree([{segmentPath: '/one/two'}]);
2132 *
2133 * // create /team/33/(user/11//right:chat)
2134 * router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: 'chat'}}]);
2135 *
2136 * // remove the right secondary node
2137 * router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: null}}]);
2138 *
2139 * // assuming the current url is `/team/33/user/11` and the route points to `user/11`
2140 *
2141 * // navigate to /team/33/user/11/details
2142 * router.createUrlTree(['details'], {relativeTo: route});
2143 *
2144 * // navigate to /team/33/user/22
2145 * router.createUrlTree(['../22'], {relativeTo: route});
2146 *
2147 * // navigate to /team/44/user/22
2148 * router.createUrlTree(['../../team/44/user/22'], {relativeTo: route});
2149 * ```
2150 */
2151 createUrlTree(commands: any[], navigationExtras?: NavigationExtras): UrlTree;
2152 /**
2153 * Navigates to a view using an absolute route path.
2154 *
2155 * @param url An absolute path for a defined route. The function does not apply any delta to the
2156 * current URL.
2157 * @param extras An object containing properties that modify the navigation strategy.
2158 * The function ignores any properties in the `NavigationExtras` that would change the
2159 * provided URL.
2160 *
2161 * @returns A Promise that resolves to 'true' when navigation succeeds,
2162 * to 'false' when navigation fails, or is rejected on error.
2163 *
2164 * @usageNotes
2165 *
2166 * The following calls request navigation to an absolute path.
2167 *
2168 * ```
2169 * router.navigateByUrl("/team/33/user/11");
2170 *
2171 * // Navigate without updating the URL
2172 * router.navigateByUrl("/team/33/user/11", { skipLocationChange: true });
2173 * ```
2174 *
2175 * @see [Routing and Navigation guide](guide/router)
2176 *
2177 */
2178 navigateByUrl(url: string | UrlTree, extras?: NavigationExtras): Promise<boolean>;
2179 /**
2180 * Navigate based on the provided array of commands and a starting point.
2181 * If no starting route is provided, the navigation is absolute.
2182 *
2183 * @param commands An array of URL fragments with which to construct the target URL.
2184 * If the path is static, can be the literal URL string. For a dynamic path, pass an array of path
2185 * segments, followed by the parameters for each segment.
2186 * The fragments are applied to the current URL or the one provided in the `relativeTo` property
2187 * of the options object, if supplied.
2188 * @param extras An options object that determines how the URL should be constructed or
2189 * interpreted.
2190 *
2191 * @returns A Promise that resolves to `true` when navigation succeeds, to `false` when navigation
2192 * fails,
2193 * or is rejected on error.
2194 *
2195 * @usageNotes
2196 *
2197 * The following calls request navigation to a dynamic route path relative to the current URL.
2198 *
2199 * ```
2200 * router.navigate(['team', 33, 'user', 11], {relativeTo: route});
2201 *
2202 * // Navigate without updating the URL, overriding the default behavior
2203 * router.navigate(['team', 33, 'user', 11], {relativeTo: route, skipLocationChange: true});
2204 * ```
2205 *
2206 * @see [Routing and Navigation guide](guide/router)
2207 *
2208 */
2209 navigate(commands: any[], extras?: NavigationExtras): Promise<boolean>;
2210 /** Serializes a `UrlTree` into a string */
2211 serializeUrl(url: UrlTree): string;
2212 /** Parses a string into a `UrlTree` */
2213 parseUrl(url: string): UrlTree;
2214 /** Returns whether the url is activated */
2215 isActive(url: string | UrlTree, exact: boolean): boolean;
2216 private removeEmptyProps;
2217 private processNavigations;
2218 private scheduleNavigation;
2219 private setBrowserUrl;
2220 private resetStateAndUrl;
2221 private resetUrlToCurrentUrlTree;
2222}
2223
2224/**
2225 * A [DI token](guide/glossary/#di-token) for the router service.
2226 *
2227 * @publicApi
2228 */
2229export declare const ROUTER_CONFIGURATION: InjectionToken<ExtraOptions>;
2230
2231/**
2232 * A [DI token](guide/glossary/#di-token) for the router initializer that
2233 * is called after the app is bootstrapped.
2234 *
2235 * @publicApi
2236 */
2237export declare const ROUTER_INITIALIZER: InjectionToken<(compRef: ComponentRef<any>) => void>;
2238
2239/**
2240 * @description
2241 *
2242 * Provides a way to customize when activated routes get reused.
2243 *
2244 * @publicApi
2245 */
2246export declare abstract class RouteReuseStrategy {
2247 /** Determines if this route (and its subtree) should be detached to be reused later */
2248 abstract shouldDetach(route: ActivatedRouteSnapshot): boolean;
2249 /**
2250 * Stores the detached route.
2251 *
2252 * Storing a `null` value should erase the previously stored value.
2253 */
2254 abstract store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle | null): void;
2255 /** Determines if this route (and its subtree) should be reattached */
2256 abstract shouldAttach(route: ActivatedRouteSnapshot): boolean;
2257 /** Retrieves the previously stored route */
2258 abstract retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null;
2259 /** Determines if a route should be reused */
2260 abstract shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean;
2261}
2262
2263/**
2264 * Base for events the router goes through, as opposed to events tied to a specific
2265 * route. Fired one time for any given navigation.
2266 *
2267 * The following code shows how a class subscribes to router events.
2268 *
2269 * ```ts
2270 * class MyService {
2271 * constructor(public router: Router, logger: Logger) {
2272 * router.events.pipe(
2273 * filter((e: Event): e is RouterEvent => e instanceof RouterEvent)
2274 * ).subscribe((e: RouterEvent) => {
2275 * logger.log(e.id, e.url);
2276 * });
2277 * }
2278 * }
2279 * ```
2280 *
2281 * @see `Event`
2282 * @see [Router events summary](guide/router#router-events)
2283 * @publicApi
2284 */
2285export declare class RouterEvent {
2286 /** A unique ID that the router assigns to every router navigation. */
2287 id: number;
2288 /** The URL that is the destination for this navigation. */
2289 url: string;
2290 constructor(
2291 /** A unique ID that the router assigns to every router navigation. */
2292 id: number,
2293 /** The URL that is the destination for this navigation. */
2294 url: string);
2295}
2296
2297/**
2298 * @description
2299 *
2300 * When applied to an element in a template, makes that element a link
2301 * that initiates navigation to a route. Navigation opens one or more routed components
2302 * in one or more `<router-outlet>` locations on the page.
2303 *
2304 * Given a route configuration `[{ path: 'user/:name', component: UserCmp }]`,
2305 * the following creates a static link to the route:
2306 * `<a routerLink="/user/bob">link to user component</a>`
2307 *
2308 * You can use dynamic values to generate the link.
2309 * For a dynamic link, pass an array of path segments,
2310 * followed by the params for each segment.
2311 * For example, `['/team', teamId, 'user', userName, {details: true}]`
2312 * generates a link to `/team/11/user/bob;details=true`.
2313 *
2314 * Multiple static segments can be merged into one term and combined with dynamic segements.
2315 * For example, `['/team/11/user', userName, {details: true}]`
2316 *
2317 * The input that you provide to the link is treated as a delta to the current URL.
2318 * For instance, suppose the current URL is `/user/(box//aux:team)`.
2319 * The link `<a [routerLink]="['/user/jim']">Jim</a>` creates the URL
2320 * `/user/(jim//aux:team)`.
2321 * See {@link Router#createUrlTree createUrlTree} for more information.
2322 *
2323 * @usageNotes
2324 *
2325 * You can use absolute or relative paths in a link, set query parameters,
2326 * control how parameters are handled, and keep a history of navigation states.
2327 *
2328 * ### Relative link paths
2329 *
2330 * The first segment name can be prepended with `/`, `./`, or `../`.
2331 * * If the first segment begins with `/`, the router looks up the route from the root of the
2332 * app.
2333 * * If the first segment begins with `./`, or doesn't begin with a slash, the router
2334 * looks in the children of the current activated route.
2335 * * If the first segment begins with `../`, the router goes up one level in the route tree.
2336 *
2337 * ### Setting and handling query params and fragments
2338 *
2339 * The following link adds a query parameter and a fragment to the generated URL:
2340 *
2341 * ```
2342 * <a [routerLink]="['/user/bob']" [queryParams]="{debug: true}" fragment="education">
2343 * link to user component
2344 * </a>
2345 * ```
2346 * By default, the directive constructs the new URL using the given query parameters.
2347 * The example generates the link: `/user/bob?debug=true#education`.
2348 *
2349 * You can instruct the directive to handle query parameters differently
2350 * by specifying the `queryParamsHandling` option in the link.
2351 * Allowed values are:
2352 *
2353 * - `'merge'`: Merge the given `queryParams` into the current query params.
2354 * - `'preserve'`: Preserve the current query params.
2355 *
2356 * For example:
2357 *
2358 * ```
2359 * <a [routerLink]="['/user/bob']" [queryParams]="{debug: true}" queryParamsHandling="merge">
2360 * link to user component
2361 * </a>
2362 * ```
2363 *
2364 * See {@link NavigationExtras.queryParamsHandling NavigationExtras#queryParamsHandling}.
2365 *
2366 * ### Preserving navigation history
2367 *
2368 * You can provide a `state` value to be persisted to the browser's
2369 * [`History.state` property](https://developer.mozilla.org/en-US/docs/Web/API/History#Properties).
2370 * For example:
2371 *
2372 * ```
2373 * <a [routerLink]="['/user/bob']" [state]="{tracingId: 123}">
2374 * link to user component
2375 * </a>
2376 * ```
2377 *
2378 * Use {@link Router.getCurrentNavigation() Router#getCurrentNavigation} to retrieve a saved
2379 * navigation-state value. For example, to capture the `tracingId` during the `NavigationStart`
2380 * event:
2381 *
2382 * ```
2383 * // Get NavigationStart events
2384 * router.events.pipe(filter(e => e instanceof NavigationStart)).subscribe(e => {
2385 * const navigation = router.getCurrentNavigation();
2386 * tracingService.trace({id: navigation.extras.state.tracingId});
2387 * });
2388 * ```
2389 *
2390 * @ngModule RouterModule
2391 *
2392 * @publicApi
2393 */
2394export declare class RouterLink {
2395 private router;
2396 private route;
2397 /**
2398 * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`.
2399 * @see {@link NavigationExtras#queryParams NavigationExtras#queryParams}
2400 * @see {@link Router#createUrlTree Router#createUrlTree}
2401 */
2402 queryParams: {
2403 [k: string]: any;
2404 };
2405 /**
2406 * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`.
2407 * @see {@link NavigationExtras#fragment NavigationExtras#fragment}
2408 * @see {@link Router#createUrlTree Router#createUrlTree}
2409 */
2410 fragment: string;
2411 /**
2412 * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`.
2413 * @see {@link NavigationExtras#queryParamsHandling NavigationExtras#queryParamsHandling}
2414 * @see {@link Router#createUrlTree Router#createUrlTree}
2415 */
2416 queryParamsHandling: QueryParamsHandling;
2417 /**
2418 * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`.
2419 * @see {@link NavigationExtras#preserveFragment NavigationExtras#preserveFragment}
2420 * @see {@link Router#createUrlTree Router#createUrlTree}
2421 */
2422 preserveFragment: boolean;
2423 /**
2424 * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`.
2425 * @see {@link NavigationExtras#skipLocationChange NavigationExtras#skipLocationChange}
2426 * @see {@link Router#createUrlTree Router#createUrlTree}
2427 */
2428 skipLocationChange: boolean;
2429 /**
2430 * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`.
2431 * @see {@link NavigationExtras#replaceUrl NavigationExtras#replaceUrl}
2432 * @see {@link Router#createUrlTree Router#createUrlTree}
2433 */
2434 replaceUrl: boolean;
2435 /**
2436 * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`.
2437 * @see {@link NavigationExtras#state NavigationExtras#state}
2438 * @see {@link Router#createUrlTree Router#createUrlTree}
2439 */
2440 state?: {
2441 [k: string]: any;
2442 };
2443 private commands;
2444 private preserve;
2445 constructor(router: Router, route: ActivatedRoute, tabIndex: string, renderer: Renderer2, el: ElementRef);
2446 /**
2447 * Commands to pass to {@link Router#createUrlTree Router#createUrlTree}.
2448 * - **array**: commands to pass to {@link Router#createUrlTree Router#createUrlTree}.
2449 * - **string**: shorthand for array of commands with just the string, i.e. `['/route']`
2450 * - **null|undefined**: shorthand for an empty array of commands, i.e. `[]`
2451 * @see {@link Router#createUrlTree Router#createUrlTree}
2452 */
2453 set routerLink(commands: any[] | string | null | undefined);
2454 /**
2455 * @deprecated As of Angular v4.0 use `queryParamsHandling` instead.
2456 */
2457 set preserveQueryParams(value: boolean);
2458 onClick(): boolean;
2459 get urlTree(): UrlTree;
2460}
2461
2462/**
2463 *
2464 * @description
2465 *
2466 * Tracks whether the linked route of an element is currently active, and allows you
2467 * to specify one or more CSS classes to add to the element when the linked route
2468 * is active.
2469 *
2470 * Use this directive to create a visual distinction for elements associated with an active route.
2471 * For example, the following code highlights the word "Bob" when the the router
2472 * activates the associated route:
2473 *
2474 * ```
2475 * <a routerLink="/user/bob" routerLinkActive="active-link">Bob</a>
2476 * ```
2477 *
2478 * Whenever the URL is either '/user' or '/user/bob', the "active-link" class is
2479 * added to the anchor tag. If the URL changes, the class is removed.
2480 *
2481 * You can set more than one class using a space-separated string or an array.
2482 * For example:
2483 *
2484 * ```
2485 * <a routerLink="/user/bob" routerLinkActive="class1 class2">Bob</a>
2486 * <a routerLink="/user/bob" [routerLinkActive]="['class1', 'class2']">Bob</a>
2487 * ```
2488 *
2489 * To add the classes only when the URL matches the link exactly, add the option `exact: true`:
2490 *
2491 * ```
2492 * <a routerLink="/user/bob" routerLinkActive="active-link" [routerLinkActiveOptions]="{exact:
2493 * true}">Bob</a>
2494 * ```
2495 *
2496 * To directly check the `isActive` status of the link, assign the `RouterLinkActive`
2497 * instance to a template variable.
2498 * For example, the following checks the status without assigning any CSS classes:
2499 *
2500 * ```
2501 * <a routerLink="/user/bob" routerLinkActive #rla="routerLinkActive">
2502 * Bob {{ rla.isActive ? '(already open)' : ''}}
2503 * </a>
2504 * ```
2505 *
2506 * You can apply the `RouterLinkActive` directive to an ancestor of linked elements.
2507 * For example, the following sets the active-link class on the `<div>` parent tag
2508 * when the URL is either '/user/jim' or '/user/bob'.
2509 *
2510 * ```
2511 * <div routerLinkActive="active-link" [routerLinkActiveOptions]="{exact: true}">
2512 * <a routerLink="/user/jim">Jim</a>
2513 * <a routerLink="/user/bob">Bob</a>
2514 * </div>
2515 * ```
2516 *
2517 * @ngModule RouterModule
2518 *
2519 * @publicApi
2520 */
2521export declare class RouterLinkActive implements OnChanges, OnDestroy, AfterContentInit {
2522 private router;
2523 private element;
2524 private renderer;
2525 private readonly cdr;
2526 private link?;
2527 private linkWithHref?;
2528 links: QueryList<RouterLink>;
2529 linksWithHrefs: QueryList<RouterLinkWithHref>;
2530 private classes;
2531 private subscription;
2532 readonly isActive: boolean;
2533 routerLinkActiveOptions: {
2534 exact: boolean;
2535 };
2536 constructor(router: Router, element: ElementRef, renderer: Renderer2, cdr: ChangeDetectorRef, link?: RouterLink | undefined, linkWithHref?: RouterLinkWithHref | undefined);
2537 ngAfterContentInit(): void;
2538 set routerLinkActive(data: string[] | string);
2539 ngOnChanges(changes: SimpleChanges): void;
2540 ngOnDestroy(): void;
2541 private update;
2542 private isLinkActive;
2543 private hasActiveLinks;
2544}
2545
2546/**
2547 * @description
2548 *
2549 * Lets you link to specific routes in your app.
2550 *
2551 * See `RouterLink` for more information.
2552 *
2553 * @ngModule RouterModule
2554 *
2555 * @publicApi
2556 */
2557export declare class RouterLinkWithHref implements OnChanges, OnDestroy {
2558 private router;
2559 private route;
2560 private locationStrategy;
2561 target: string;
2562 /**
2563 * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`.
2564 * @see {@link NavigationExtras#queryParams NavigationExtras#queryParams}
2565 * @see {@link Router#createUrlTree Router#createUrlTree}
2566 */
2567 queryParams: {
2568 [k: string]: any;
2569 };
2570 /**
2571 * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`.
2572 * @see {@link NavigationExtras#fragment NavigationExtras#fragment}
2573 * @see {@link Router#createUrlTree Router#createUrlTree}
2574 */
2575 fragment: string;
2576 /**
2577 * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`.
2578 * @see {@link NavigationExtras#queryParamsHandling NavigationExtras#queryParamsHandling}
2579 * @see {@link Router#createUrlTree Router#createUrlTree}
2580 */
2581 queryParamsHandling: QueryParamsHandling;
2582 /**
2583 * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`.
2584 * @see {@link NavigationExtras#preserveFragment NavigationExtras#preserveFragment}
2585 * @see {@link Router#createUrlTree Router#createUrlTree}
2586 */
2587 preserveFragment: boolean;
2588 /**
2589 * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`.
2590 * @see {@link NavigationExtras#skipLocationChange NavigationExtras#skipLocationChange}
2591 * @see {@link Router#createUrlTree Router#createUrlTree}
2592 */
2593 skipLocationChange: boolean;
2594 /**
2595 * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`.
2596 * @see {@link NavigationExtras#replaceUrl NavigationExtras#replaceUrl}
2597 * @see {@link Router#createUrlTree Router#createUrlTree}
2598 */
2599 replaceUrl: boolean;
2600 /**
2601 * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the `NavigationExtras`.
2602 * @see {@link NavigationExtras#state NavigationExtras#state}
2603 * @see {@link Router#createUrlTree Router#createUrlTree}
2604 */
2605 state?: {
2606 [k: string]: any;
2607 };
2608 private commands;
2609 private subscription;
2610 private preserve;
2611 href: string;
2612 constructor(router: Router, route: ActivatedRoute, locationStrategy: LocationStrategy);
2613 /**
2614 * Commands to pass to {@link Router#createUrlTree Router#createUrlTree}.
2615 * - **array**: commands to pass to {@link Router#createUrlTree Router#createUrlTree}.
2616 * - **string**: shorthand for array of commands with just the string, i.e. `['/route']`
2617 * - **null|undefined**: shorthand for an empty array of commands, i.e. `[]`
2618 * @see {@link Router#createUrlTree Router#createUrlTree}
2619 */
2620 set routerLink(commands: any[] | string | null | undefined);
2621 /**
2622 * @deprecated As of Angular v4.0 use `queryParamsHandling` instead.
2623 */
2624 set preserveQueryParams(value: boolean);
2625 ngOnChanges(changes: {}): any;
2626 ngOnDestroy(): any;
2627 onClick(button: number, ctrlKey: boolean, metaKey: boolean, shiftKey: boolean): boolean;
2628 private updateTargetUrlAndHref;
2629 get urlTree(): UrlTree;
2630}
2631
2632/**
2633 * @description
2634 *
2635 * Adds directives and providers for in-app navigation among views defined in an application.
2636 * Use the Angular `Router` service to declaratively specify application states and manage state
2637 * transitions.
2638 *
2639 * You can import this NgModule multiple times, once for each lazy-loaded bundle.
2640 * However, only one `Router` service can be active.
2641 * To ensure this, there are two ways to register routes when importing this module:
2642 *
2643 * * The `forRoot()` method creates an `NgModule` that contains all the directives, the given
2644 * routes, and the `Router` service itself.
2645 * * The `forChild()` method creates an `NgModule` that contains all the directives and the given
2646 * routes, but does not include the `Router` service.
2647 *
2648 * @see [Routing and Navigation guide](guide/router) for an
2649 * overview of how the `Router` service should be used.
2650 *
2651 * @publicApi
2652 */
2653export declare class RouterModule {
2654 constructor(guard: any, router: Router);
2655 /**
2656 * Creates and configures a module with all the router providers and directives.
2657 * Optionally sets up an application listener to perform an initial navigation.
2658 *
2659 * When registering the NgModule at the root, import as follows:
2660 *
2661 * ```
2662 * @NgModule({
2663 * imports: [RouterModule.forRoot(ROUTES)]
2664 * })
2665 * class MyNgModule {}
2666 * ```
2667 *
2668 * @param routes An array of `Route` objects that define the navigation paths for the application.
2669 * @param config An `ExtraOptions` configuration object that controls how navigation is performed.
2670 * @return The new `NgModule`.
2671 *
2672 */
2673 static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders<RouterModule>;
2674 /**
2675 * Creates a module with all the router directives and a provider registering routes,
2676 * without creating a new Router service.
2677 * When registering for submodules and lazy-loaded submodules, create the NgModule as follows:
2678 *
2679 * ```
2680 * @NgModule({
2681 * imports: [RouterModule.forChild(ROUTES)]
2682 * })
2683 * class MyNgModule {}
2684 * ```
2685 *
2686 * @param routes An array of `Route` objects that define the navigation paths for the submodule.
2687 * @return The new NgModule.
2688 *
2689 */
2690 static forChild(routes: Routes): ModuleWithProviders<RouterModule>;
2691}
2692
2693/**
2694 * @description
2695 *
2696 * Acts as a placeholder that Angular dynamically fills based on the current router state.
2697 *
2698 * Each outlet can have a unique name, determined by the optional `name` attribute.
2699 * The name cannot be set or changed dynamically. If not set, default value is "primary".
2700 *
2701 * ```
2702 * <router-outlet></router-outlet>
2703 * <router-outlet name='left'></router-outlet>
2704 * <router-outlet name='right'></router-outlet>
2705 * ```
2706 *
2707 * Named outlets can be the targets of secondary routes.
2708 * The `Route` object for a secondary route has an `outlet` property to identify the target outlet:
2709 *
2710 * `{path: <base-path>, component: <component>, outlet: <target_outlet_name>}`
2711 *
2712 * Using named outlets and secondary routes, you can target multiple outlets in
2713 * the same `RouterLink` directive.
2714 *
2715 * The router keeps track of separate branches in a navigation tree for each named outlet and
2716 * generates a representation of that tree in the URL.
2717 * The URL for a secondary route uses the following syntax to specify both the primary and secondary
2718 * routes at the same time:
2719 *
2720 * `http://base-path/primary-route-path(outlet-name:route-path)`
2721 *
2722 * A router outlet emits an activate event when a new component is instantiated,
2723 * and a deactivate event when a component is destroyed.
2724 *
2725 * ```
2726 * <router-outlet
2727 * (activate)='onActivate($event)'
2728 * (deactivate)='onDeactivate($event)'></router-outlet>
2729 * ```
2730 *
2731 * @see [Routing tutorial](guide/router-tutorial-toh#named-outlets "Example of a named
2732 * outlet and secondary route configuration").
2733 * @see `RouterLink`
2734 * @see `Route`
2735 * @ngModule RouterModule
2736 *
2737 * @publicApi
2738 */
2739export declare class RouterOutlet implements OnDestroy, OnInit {
2740 private parentContexts;
2741 private location;
2742 private resolver;
2743 private changeDetector;
2744 private activated;
2745 private _activatedRoute;
2746 private name;
2747 activateEvents: EventEmitter<any>;
2748 deactivateEvents: EventEmitter<any>;
2749 constructor(parentContexts: ChildrenOutletContexts, location: ViewContainerRef, resolver: ComponentFactoryResolver, name: string, changeDetector: ChangeDetectorRef);
2750 ngOnDestroy(): void;
2751 ngOnInit(): void;
2752 get isActivated(): boolean;
2753 get component(): Object;
2754 get activatedRoute(): ActivatedRoute;
2755 get activatedRouteData(): Data;
2756 /**
2757 * Called when the `RouteReuseStrategy` instructs to detach the subtree
2758 */
2759 detach(): ComponentRef<any>;
2760 /**
2761 * Called when the `RouteReuseStrategy` instructs to re-attach a previously detached subtree
2762 */
2763 attach(ref: ComponentRef<any>, activatedRoute: ActivatedRoute): void;
2764 deactivate(): void;
2765 activateWith(activatedRoute: ActivatedRoute, resolver: ComponentFactoryResolver | null): void;
2766}
2767
2768/**
2769 * The preloader optimistically loads all router configurations to
2770 * make navigations into lazily-loaded sections of the application faster.
2771 *
2772 * The preloader runs in the background. When the router bootstraps, the preloader
2773 * starts listening to all navigation events. After every such event, the preloader
2774 * will check if any configurations can be loaded lazily.
2775 *
2776 * If a route is protected by `canLoad` guards, the preloaded will not load it.
2777 *
2778 * @publicApi
2779 */
2780export declare class RouterPreloader implements OnDestroy {
2781 private router;
2782 private injector;
2783 private preloadingStrategy;
2784 private loader;
2785 private subscription?;
2786 constructor(router: Router, moduleLoader: NgModuleFactoryLoader, compiler: Compiler, injector: Injector, preloadingStrategy: PreloadingStrategy);
2787 setUpPreloading(): void;
2788 preload(): Observable<any>;
2789 ngOnDestroy(): void;
2790 private processRoutes;
2791 private preloadConfig;
2792}
2793
2794/**
2795 * Represents the state of the router as a tree of activated routes.
2796 *
2797 * @usageNotes
2798 *
2799 * Every node in the route tree is an `ActivatedRoute` instance
2800 * that knows about the "consumed" URL segments, the extracted parameters,
2801 * and the resolved data.
2802 * Use the `ActivatedRoute` properties to traverse the tree from any node.
2803 *
2804 * The following fragment shows how a component gets the root node
2805 * of the current state to establish its own route tree:
2806 *
2807 * ```
2808 * @Component({templateUrl:'template.html'})
2809 * class MyComponent {
2810 * constructor(router: Router) {
2811 * const state: RouterState = router.routerState;
2812 * const root: ActivatedRoute = state.root;
2813 * const child = root.firstChild;
2814 * const id: Observable<string> = child.params.map(p => p.id);
2815 * //...
2816 * }
2817 * }
2818 * ```
2819 *
2820 * @see `ActivatedRoute`
2821 * @see [Getting route information](guide/router#getting-route-information)
2822 *
2823 * @publicApi
2824 */
2825export declare class RouterState extends ɵangular_packages_router_router_m<ActivatedRoute> {
2826 /** The current snapshot of the router state */
2827 snapshot: RouterStateSnapshot;
2828 toString(): string;
2829}
2830
2831/**
2832 * @description
2833 *
2834 * Represents the state of the router at a moment in time.
2835 *
2836 * This is a tree of activated route snapshots. Every node in this tree knows about
2837 * the "consumed" URL segments, the extracted parameters, and the resolved data.
2838 *
2839 * The following example shows how a component is initialized with information
2840 * from the snapshot of the root node's state at the time of creation.
2841 *
2842 * ```
2843 * @Component({templateUrl:'template.html'})
2844 * class MyComponent {
2845 * constructor(router: Router) {
2846 * const state: RouterState = router.routerState;
2847 * const snapshot: RouterStateSnapshot = state.snapshot;
2848 * const root: ActivatedRouteSnapshot = snapshot.root;
2849 * const child = root.firstChild;
2850 * const id: Observable<string> = child.params.map(p => p.id);
2851 * //...
2852 * }
2853 * }
2854 * ```
2855 *
2856 * @publicApi
2857 */
2858export declare class RouterStateSnapshot extends ɵangular_packages_router_router_m<ActivatedRouteSnapshot> {
2859 /** The url from which this snapshot was created */
2860 url: string;
2861 toString(): string;
2862}
2863
2864/**
2865 * The [DI token](guide/glossary/#di-token) for a router configuration.
2866 * @see `ROUTES`
2867 * @publicApi
2868 */
2869export declare const ROUTES: InjectionToken<Route[][]>;
2870
2871/**
2872 * Represents a route configuration for the Router service.
2873 * An array of `Route` objects, used in `Router.config` and for nested route configurations
2874 * in `Route.children`.
2875 *
2876 * @see `Route`
2877 * @see `Router`
2878 * @see [Router configuration guide](guide/router#configuration)
2879 * @publicApi
2880 */
2881export declare type Routes = Route[];
2882
2883/**
2884 * An event triggered when routes are recognized.
2885 *
2886 * @publicApi
2887 */
2888export declare class RoutesRecognized extends RouterEvent {
2889 /** @docsNotRequired */
2890 urlAfterRedirects: string;
2891 /** @docsNotRequired */
2892 state: RouterStateSnapshot;
2893 constructor(
2894 /** @docsNotRequired */
2895 id: number,
2896 /** @docsNotRequired */
2897 url: string,
2898 /** @docsNotRequired */
2899 urlAfterRedirects: string,
2900 /** @docsNotRequired */
2901 state: RouterStateSnapshot);
2902 /** @docsNotRequired */
2903 toString(): string;
2904}
2905
2906/**
2907 *
2908 * A policy for when to run guards and resolvers on a route.
2909 *
2910 * @see [Route.runGuardsAndResolvers](api/router/Route#runGuardsAndResolvers)
2911 * @publicApi
2912 */
2913export declare type RunGuardsAndResolvers = 'pathParamsChange' | 'pathParamsOrQueryParamsChange' | 'paramsChange' | 'paramsOrQueryParamsChange' | 'always' | ((from: ActivatedRouteSnapshot, to: ActivatedRouteSnapshot) => boolean);
2914
2915/**
2916 * An event triggered by scrolling.
2917 *
2918 * @publicApi
2919 */
2920export declare class Scroll {
2921 /** @docsNotRequired */
2922 readonly routerEvent: NavigationEnd;
2923 /** @docsNotRequired */
2924 readonly position: [number, number] | null;
2925 /** @docsNotRequired */
2926 readonly anchor: string | null;
2927 constructor(
2928 /** @docsNotRequired */
2929 routerEvent: NavigationEnd,
2930 /** @docsNotRequired */
2931 position: [number, number] | null,
2932 /** @docsNotRequired */
2933 anchor: string | null);
2934 toString(): string;
2935}
2936
2937/**
2938 * @description
2939 *
2940 * Provides a way to migrate AngularJS applications to Angular.
2941 *
2942 * @publicApi
2943 */
2944export declare abstract class UrlHandlingStrategy {
2945 /**
2946 * Tells the router if this URL should be processed.
2947 *
2948 * When it returns true, the router will execute the regular navigation.
2949 * When it returns false, the router will set the router state to an empty state.
2950 * As a result, all the active components will be destroyed.
2951 *
2952 */
2953 abstract shouldProcessUrl(url: UrlTree): boolean;
2954 /**
2955 * Extracts the part of the URL that should be handled by the router.
2956 * The rest of the URL will remain untouched.
2957 */
2958 abstract extract(url: UrlTree): UrlTree;
2959 /**
2960 * Merges the URL fragment with the rest of the URL.
2961 */
2962 abstract merge(newUrlPart: UrlTree, rawUrl: UrlTree): UrlTree;
2963}
2964
2965/**
2966 * A function for matching a route against URLs. Implement a custom URL matcher
2967 * for `Route.matcher` when a combination of `path` and `pathMatch`
2968 * is not expressive enough. Cannot be used together with `path` and `pathMatch`.
2969 *
2970 * The function takes the following arguments and returns a `UrlMatchResult` object.
2971 * * *segments* : An array of URL segments.
2972 * * *group* : A segment group.
2973 * * *route* : The route to match against.
2974 *
2975 * The following example implementation matches HTML files.
2976 *
2977 * ```
2978 * export function htmlFiles(url: UrlSegment[]) {
2979 * return url.length === 1 && url[0].path.endsWith('.html') ? ({consumed: url}) : null;
2980 * }
2981 *
2982 * export const routes = [{ matcher: htmlFiles, component: AnyComponent }];
2983 * ```
2984 *
2985 * @publicApi
2986 */
2987export declare type UrlMatcher = (segments: UrlSegment[], group: UrlSegmentGroup, route: Route) => UrlMatchResult | null;
2988
2989/**
2990 * Represents the result of matching URLs with a custom matching function.
2991 *
2992 * * `consumed` is an array of the consumed URL segments.
2993 * * `posParams` is a map of positional parameters.
2994 *
2995 * @see `UrlMatcher()`
2996 * @publicApi
2997 */
2998export declare type UrlMatchResult = {
2999 consumed: UrlSegment[];
3000 posParams?: {
3001 [name: string]: UrlSegment;
3002 };
3003};
3004
3005/**
3006 * @description
3007 *
3008 * Represents a single URL segment.
3009 *
3010 * A UrlSegment is a part of a URL between the two slashes. It contains a path and the matrix
3011 * parameters associated with the segment.
3012 *
3013 * @usageNotes
3014 * ### Example
3015 *
3016 * ```
3017 * @Component({templateUrl:'template.html'})
3018 * class MyComponent {
3019 * constructor(router: Router) {
3020 * const tree: UrlTree = router.parseUrl('/team;id=33');
3021 * const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET];
3022 * const s: UrlSegment[] = g.segments;
3023 * s[0].path; // returns 'team'
3024 * s[0].parameters; // returns {id: 33}
3025 * }
3026 * }
3027 * ```
3028 *
3029 * @publicApi
3030 */
3031export declare class UrlSegment {
3032 /** The path part of a URL segment */
3033 path: string;
3034 /** The matrix parameters associated with a segment */
3035 parameters: {
3036 [name: string]: string;
3037 };
3038 constructor(
3039 /** The path part of a URL segment */
3040 path: string,
3041 /** The matrix parameters associated with a segment */
3042 parameters: {
3043 [name: string]: string;
3044 });
3045 get parameterMap(): ParamMap;
3046 /** @docsNotRequired */
3047 toString(): string;
3048}
3049
3050/**
3051 * @description
3052 *
3053 * Represents the parsed URL segment group.
3054 *
3055 * See `UrlTree` for more information.
3056 *
3057 * @publicApi
3058 */
3059export declare class UrlSegmentGroup {
3060 /** The URL segments of this group. See `UrlSegment` for more information */
3061 segments: UrlSegment[];
3062 /** The list of children of this group */
3063 children: {
3064 [key: string]: UrlSegmentGroup;
3065 };
3066 /** The parent node in the url tree */
3067 parent: UrlSegmentGroup | null;
3068 constructor(
3069 /** The URL segments of this group. See `UrlSegment` for more information */
3070 segments: UrlSegment[],
3071 /** The list of children of this group */
3072 children: {
3073 [key: string]: UrlSegmentGroup;
3074 });
3075 /** Whether the segment has child segments */
3076 hasChildren(): boolean;
3077 /** Number of child segments */
3078 get numberOfChildren(): number;
3079 /** @docsNotRequired */
3080 toString(): string;
3081}
3082
3083/**
3084 * @description
3085 *
3086 * Serializes and deserializes a URL string into a URL tree.
3087 *
3088 * The url serialization strategy is customizable. You can
3089 * make all URLs case insensitive by providing a custom UrlSerializer.
3090 *
3091 * See `DefaultUrlSerializer` for an example of a URL serializer.
3092 *
3093 * @publicApi
3094 */
3095export declare abstract class UrlSerializer {
3096 /** Parse a url into a `UrlTree` */
3097 abstract parse(url: string): UrlTree;
3098 /** Converts a `UrlTree` into a url */
3099 abstract serialize(tree: UrlTree): string;
3100}
3101
3102/**
3103 * @description
3104 *
3105 * Represents the parsed URL.
3106 *
3107 * Since a router state is a tree, and the URL is nothing but a serialized state, the URL is a
3108 * serialized tree.
3109 * UrlTree is a data structure that provides a lot of affordances in dealing with URLs
3110 *
3111 * @usageNotes
3112 * ### Example
3113 *
3114 * ```
3115 * @Component({templateUrl:'template.html'})
3116 * class MyComponent {
3117 * constructor(router: Router) {
3118 * const tree: UrlTree =
3119 * router.parseUrl('/team/33/(user/victor//support:help)?debug=true#fragment');
3120 * const f = tree.fragment; // return 'fragment'
3121 * const q = tree.queryParams; // returns {debug: 'true'}
3122 * const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET];
3123 * const s: UrlSegment[] = g.segments; // returns 2 segments 'team' and '33'
3124 * g.children[PRIMARY_OUTLET].segments; // returns 2 segments 'user' and 'victor'
3125 * g.children['support'].segments; // return 1 segment 'help'
3126 * }
3127 * }
3128 * ```
3129 *
3130 * @publicApi
3131 */
3132export declare class UrlTree {
3133 /** The root segment group of the URL tree */
3134 root: UrlSegmentGroup;
3135 /** The query params of the URL */
3136 queryParams: Params;
3137 /** The fragment of the URL */
3138 fragment: string | null;
3139 get queryParamMap(): ParamMap;
3140 /** @docsNotRequired */
3141 toString(): string;
3142}
3143
3144/**
3145 * @publicApi
3146 */
3147export declare const VERSION: Version;
3148
3149/**
3150 * @docsNotRequired
3151 */
3152export declare const ɵangular_packages_router_router_a: InjectionToken<void>;
3153
3154export declare function ɵangular_packages_router_router_b(): NgProbeToken;
3155
3156export declare function ɵangular_packages_router_router_c(router: Router, viewportScroller: ViewportScroller, config: ExtraOptions): ɵangular_packages_router_router_o;
3157
3158export declare function ɵangular_packages_router_router_d(platformLocationStrategy: PlatformLocation, baseHref: string, options?: ExtraOptions): HashLocationStrategy | PathLocationStrategy;
3159
3160export declare function ɵangular_packages_router_router_e(router: Router): any;
3161
3162export 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;
3163
3164export declare function ɵangular_packages_router_router_g(router: Router): ActivatedRoute;
3165
3166/**
3167 * Router initialization requires two steps:
3168 *
3169 * First, we start the navigation in a `APP_INITIALIZER` to block the bootstrap if
3170 * a resolver or a guard executes asynchronously.
3171 *
3172 * Next, we actually run activation in a `BOOTSTRAP_LISTENER`, using the
3173 * `afterPreactivation` hook provided by the router.
3174 * The router navigation starts, reaches the point when preactivation is done, and then
3175 * pauses. It waits for the hook to be resolved. We then resolve it only in a bootstrap listener.
3176 */
3177export declare class ɵangular_packages_router_router_h {
3178 private injector;
3179 private initNavigation;
3180 private resultOfPreactivationDone;
3181 constructor(injector: Injector);
3182 appInitializer(): Promise<any>;
3183 bootstrapListener(bootstrappedComponentRef: ComponentRef<any>): void;
3184 private isLegacyEnabled;
3185 private isLegacyDisabled;
3186}
3187
3188export declare function ɵangular_packages_router_router_i(r: ɵangular_packages_router_router_h): () => Promise<any>;
3189
3190export declare function ɵangular_packages_router_router_j(r: ɵangular_packages_router_router_h): (bootstrappedComponentRef: ComponentRef<any>) => void;
3191
3192export declare function ɵangular_packages_router_router_k(): (typeof ɵangular_packages_router_router_h | {
3193 provide: InjectionToken<(() => void)[]>;
3194 multi: boolean;
3195 useFactory: typeof ɵangular_packages_router_router_i;
3196 deps: (typeof ɵangular_packages_router_router_h)[];
3197 useExisting?: undefined;
3198} | {
3199 provide: InjectionToken<(compRef: ComponentRef<any>) => void>;
3200 useFactory: typeof ɵangular_packages_router_router_j;
3201 deps: (typeof ɵangular_packages_router_router_h)[];
3202 multi?: undefined;
3203 useExisting?: undefined;
3204} | {
3205 provide: InjectionToken<((compRef: ComponentRef<any>) => void)[]>;
3206 multi: boolean;
3207 useExisting: InjectionToken<(compRef: ComponentRef<any>) => void>;
3208 useFactory?: undefined;
3209 deps?: undefined;
3210})[];
3211
3212
3213export declare class ɵangular_packages_router_router_m<T> {
3214 constructor(root: ɵangular_packages_router_router_n<T>);
3215 get root(): T;
3216}
3217
3218export declare class ɵangular_packages_router_router_n<T> {
3219 value: T;
3220 children: ɵangular_packages_router_router_n<T>[];
3221 constructor(value: T, children: ɵangular_packages_router_router_n<T>[]);
3222 toString(): string;
3223}
3224
3225export declare class ɵangular_packages_router_router_o implements OnDestroy {
3226 private router;
3227 /** @docsNotRequired */ readonly viewportScroller: ViewportScroller;
3228 private options;
3229 private routerEventsSubscription;
3230 private scrollEventsSubscription;
3231 private lastId;
3232 private lastSource;
3233 private restoredId;
3234 private store;
3235 constructor(router: Router,
3236 /** @docsNotRequired */ viewportScroller: ViewportScroller, options?: {
3237 scrollPositionRestoration?: 'disabled' | 'enabled' | 'top';
3238 anchorScrolling?: 'disabled' | 'enabled';
3239 });
3240 init(): void;
3241 private createScrollEvents;
3242 private consumeScrollEvents;
3243 private scheduleScrollEvent;
3244 ngOnDestroy(): void;
3245}
3246
3247
3248/**
3249 * This component is used internally within the router to be a placeholder when an empty
3250 * router-outlet is needed. For example, with a config such as:
3251 *
3252 * `{path: 'parent', outlet: 'nav', children: [...]}`
3253 *
3254 * In order to render, there needs to be a component on this config, which will default
3255 * to this `EmptyOutletComponent`.
3256 */
3257declare class ɵEmptyOutletComponent {
3258}
3259export { ɵEmptyOutletComponent }
3260export { ɵEmptyOutletComponent as ɵangular_packages_router_router_l }
3261
3262/**
3263 * Flattens single-level nested arrays.
3264 */
3265export declare function ɵflatten<T>(arr: T[][]): T[];
3266
3267export declare const ɵROUTER_PROVIDERS: Provider[];
3268
3269export { }
3270
\No newline at end of file