@angular/router 20.0.0-next.4 → 20.0.0-next.6

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