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