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