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