UNPKG

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