UNPKG

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