@angular/router 10.0.4 → 10.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/router-testing.umd.js +1 -1
- package/bundles/router-testing.umd.min.js +1 -1
- package/bundles/router-testing.umd.min.js.map +1 -1
- package/bundles/router-upgrade.umd.js +1 -1
- package/bundles/router-upgrade.umd.min.js +1 -1
- package/bundles/router-upgrade.umd.min.js.map +1 -1
- package/bundles/router.umd.js +111 -77
- package/bundles/router.umd.js.map +1 -1
- package/bundles/router.umd.min.js +2 -2
- package/bundles/router.umd.min.js.map +1 -1
- package/esm2015/src/config.js +1 -1
- package/esm2015/src/events.js +29 -7
- package/esm2015/src/interfaces.js +1 -1
- package/esm2015/src/router.js +32 -23
- package/esm2015/src/router_module.js +38 -45
- package/esm2015/src/router_state.js +14 -4
- package/esm2015/src/version.js +1 -1
- package/fesm2015/router.js +111 -77
- package/fesm2015/router.js.map +1 -1
- package/fesm2015/testing.js +1 -1
- package/fesm2015/upgrade.js +1 -1
- package/package.json +4 -4
- package/router.d.ts +308 -152
- package/router.metadata.json +1 -1
- package/testing/testing.d.ts +1 -1
- package/testing.d.ts +1 -1
- package/upgrade/upgrade.d.ts +1 -1
- package/upgrade.d.ts +1 -1
package/router.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v10.0.
|
|
2
|
+
* @license Angular v10.0.5
|
|
3
3
|
* (c) 2010-2020 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -40,9 +40,14 @@ import { ViewportScroller } from '@angular/common';
|
|
|
40
40
|
* that is loaded in an outlet.
|
|
41
41
|
* Use to traverse the `RouterState` tree and extract information from nodes.
|
|
42
42
|
*
|
|
43
|
+
* The following example shows how to construct a component using information from a
|
|
44
|
+
* currently activated route.
|
|
45
|
+
*
|
|
43
46
|
* {@example router/activated-route/module.ts region="activated-route"
|
|
44
47
|
* header="activated-route.component.ts"}
|
|
45
48
|
*
|
|
49
|
+
* @see [Getting route information](guide/router#getting-route-information)
|
|
50
|
+
*
|
|
46
51
|
* @publicApi
|
|
47
52
|
*/
|
|
48
53
|
export declare class ActivatedRoute {
|
|
@@ -95,6 +100,9 @@ export declare class ActivatedRoute {
|
|
|
95
100
|
* outlet at a particular moment in time. ActivatedRouteSnapshot can also be used to
|
|
96
101
|
* traverse the router state tree.
|
|
97
102
|
*
|
|
103
|
+
* The following example initializes a component with route information extracted
|
|
104
|
+
* from the snapshot of the root node at the time of creation.
|
|
105
|
+
*
|
|
98
106
|
* ```
|
|
99
107
|
* @Component({templateUrl:'./my-component.html'})
|
|
100
108
|
* class MyComponent {
|
|
@@ -160,7 +168,7 @@ export declare class ActivationEnd {
|
|
|
160
168
|
/**
|
|
161
169
|
* An event triggered at the start of the activation part
|
|
162
170
|
* of the Resolve phase of routing.
|
|
163
|
-
* @see ActivationEnd`
|
|
171
|
+
* @see `ActivationEnd`
|
|
164
172
|
* @see `ResolveStart`
|
|
165
173
|
*
|
|
166
174
|
* @publicApi
|
|
@@ -178,10 +186,12 @@ export declare class ActivationStart {
|
|
|
178
186
|
* @description
|
|
179
187
|
*
|
|
180
188
|
* Interface that a class can implement to be a guard deciding if a route can be activated.
|
|
181
|
-
* If all guards return `true`, navigation
|
|
182
|
-
* navigation
|
|
183
|
-
*
|
|
184
|
-
*
|
|
189
|
+
* If all guards return `true`, navigation continues. If any guard returns `false`,
|
|
190
|
+
* navigation is cancelled. If any guard returns a `UrlTree`, the current navigation
|
|
191
|
+
* is cancelled and a new navigation begins to the `UrlTree` returned from the guard.
|
|
192
|
+
*
|
|
193
|
+
* The following example implements a `CanActivate` function that checks whether the
|
|
194
|
+
* current user has permission to activate the requested route.
|
|
185
195
|
*
|
|
186
196
|
* ```
|
|
187
197
|
* class UserToken {}
|
|
@@ -202,7 +212,12 @@ export declare class ActivationStart {
|
|
|
202
212
|
* return this.permissions.canActivate(this.currentUser, route.params.id);
|
|
203
213
|
* }
|
|
204
214
|
* }
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* Here, the defined guard function is provided as part of the `Route` object
|
|
218
|
+
* in the router configuration:
|
|
205
219
|
*
|
|
220
|
+
* ```
|
|
206
221
|
* @NgModule({
|
|
207
222
|
* imports: [
|
|
208
223
|
* RouterModule.forRoot([
|
|
@@ -218,7 +233,7 @@ export declare class ActivationStart {
|
|
|
218
233
|
* class AppModule {}
|
|
219
234
|
* ```
|
|
220
235
|
*
|
|
221
|
-
* You can alternatively provide
|
|
236
|
+
* You can alternatively provide an in-line function with the `canActivate` signature:
|
|
222
237
|
*
|
|
223
238
|
* ```
|
|
224
239
|
* @NgModule({
|
|
@@ -251,10 +266,12 @@ export declare interface CanActivate {
|
|
|
251
266
|
* @description
|
|
252
267
|
*
|
|
253
268
|
* Interface that a class can implement to be a guard deciding if a child route can be activated.
|
|
254
|
-
* If all guards return `true`, navigation
|
|
255
|
-
* navigation
|
|
256
|
-
*
|
|
257
|
-
*
|
|
269
|
+
* If all guards return `true`, navigation continues. If any guard returns `false`,
|
|
270
|
+
* navigation is cancelled. If any guard returns a `UrlTree`, current navigation
|
|
271
|
+
* is cancelled and a new navigation begins to the `UrlTree` returned from the guard.
|
|
272
|
+
*
|
|
273
|
+
* The following example implements a `CanActivateChild` function that checks whether the
|
|
274
|
+
* current user has permission to activate the requested child route.
|
|
258
275
|
*
|
|
259
276
|
* ```
|
|
260
277
|
* class UserToken {}
|
|
@@ -275,7 +292,12 @@ export declare interface CanActivate {
|
|
|
275
292
|
* return this.permissions.canActivate(this.currentUser, route.params.id);
|
|
276
293
|
* }
|
|
277
294
|
* }
|
|
295
|
+
* ```
|
|
296
|
+
*
|
|
297
|
+
* Here, the defined guard function is provided as part of the `Route` object
|
|
298
|
+
* in the router configuration:
|
|
278
299
|
*
|
|
300
|
+
* ```
|
|
279
301
|
* @NgModule({
|
|
280
302
|
* imports: [
|
|
281
303
|
* RouterModule.forRoot([
|
|
@@ -296,7 +318,7 @@ export declare interface CanActivate {
|
|
|
296
318
|
* class AppModule {}
|
|
297
319
|
* ```
|
|
298
320
|
*
|
|
299
|
-
* You can alternatively provide
|
|
321
|
+
* You can alternatively provide an in-line function with the `canActivateChild` signature:
|
|
300
322
|
*
|
|
301
323
|
* ```
|
|
302
324
|
* @NgModule({
|
|
@@ -334,10 +356,12 @@ export declare interface CanActivateChild {
|
|
|
334
356
|
* @description
|
|
335
357
|
*
|
|
336
358
|
* Interface that a class can implement to be a guard deciding if a route can be deactivated.
|
|
337
|
-
* If all guards return `true`, navigation
|
|
338
|
-
* navigation
|
|
339
|
-
*
|
|
340
|
-
*
|
|
359
|
+
* If all guards return `true`, navigation continues. If any guard returns `false`,
|
|
360
|
+
* navigation is cancelled. If any guard returns a `UrlTree`, current navigation
|
|
361
|
+
* is cancelled and a new navigation begins to the `UrlTree` returned from the guard.
|
|
362
|
+
*
|
|
363
|
+
* The following example implements a `CanDeactivate` function that checks whether the
|
|
364
|
+
* current user has permission to deactivate the requested route.
|
|
341
365
|
*
|
|
342
366
|
* ```
|
|
343
367
|
* class UserToken {}
|
|
@@ -346,6 +370,12 @@ export declare interface CanActivateChild {
|
|
|
346
370
|
* return true;
|
|
347
371
|
* }
|
|
348
372
|
* }
|
|
373
|
+
* ```
|
|
374
|
+
*
|
|
375
|
+
* Here, the defined guard function is provided as part of the `Route` object
|
|
376
|
+
* in the router configuration:
|
|
377
|
+
*
|
|
378
|
+
* ```
|
|
349
379
|
*
|
|
350
380
|
* @Injectable()
|
|
351
381
|
* class CanDeactivateTeam implements CanDeactivate<TeamComponent> {
|
|
@@ -376,7 +406,7 @@ export declare interface CanActivateChild {
|
|
|
376
406
|
* class AppModule {}
|
|
377
407
|
* ```
|
|
378
408
|
*
|
|
379
|
-
* You can alternatively provide
|
|
409
|
+
* You can alternatively provide an in-line function with the `canDeactivate` signature:
|
|
380
410
|
*
|
|
381
411
|
* ```
|
|
382
412
|
* @NgModule({
|
|
@@ -410,10 +440,13 @@ export declare interface CanDeactivate<T> {
|
|
|
410
440
|
* @description
|
|
411
441
|
*
|
|
412
442
|
* Interface that a class can implement to be a guard deciding if children can be loaded.
|
|
413
|
-
* If all guards return `true`, navigation
|
|
414
|
-
* navigation
|
|
415
|
-
*
|
|
416
|
-
*
|
|
443
|
+
* If all guards return `true`, navigation continues. If any guard returns `false`,
|
|
444
|
+
* navigation is cancelled. If any guard returns a `UrlTree`, current navigation
|
|
445
|
+
* is cancelled and a new navigation starts to the `UrlTree` returned from the guard.
|
|
446
|
+
*
|
|
447
|
+
* The following example implements a `CanLoad` function that decides whether the
|
|
448
|
+
* current user has permission to load requested child routes.
|
|
449
|
+
*
|
|
417
450
|
*
|
|
418
451
|
* ```
|
|
419
452
|
* class UserToken {}
|
|
@@ -431,6 +464,12 @@ export declare interface CanDeactivate<T> {
|
|
|
431
464
|
* return this.permissions.canLoadChildren(this.currentUser, route, segments);
|
|
432
465
|
* }
|
|
433
466
|
* }
|
|
467
|
+
* ```
|
|
468
|
+
*
|
|
469
|
+
* Here, the defined guard function is provided as part of the `Route` object
|
|
470
|
+
* in the router configuration:
|
|
471
|
+
*
|
|
472
|
+
* ```
|
|
434
473
|
*
|
|
435
474
|
* @NgModule({
|
|
436
475
|
* imports: [
|
|
@@ -448,7 +487,7 @@ export declare interface CanDeactivate<T> {
|
|
|
448
487
|
* class AppModule {}
|
|
449
488
|
* ```
|
|
450
489
|
*
|
|
451
|
-
* You can alternatively provide
|
|
490
|
+
* You can alternatively provide an in-line function with the `canLoad` signature:
|
|
452
491
|
*
|
|
453
492
|
* ```
|
|
454
493
|
* @NgModule({
|
|
@@ -482,7 +521,7 @@ export declare interface CanLoad {
|
|
|
482
521
|
* An event triggered at the end of the child-activation part
|
|
483
522
|
* of the Resolve phase of routing.
|
|
484
523
|
* @see `ChildActivationStart`
|
|
485
|
-
* @see `ResolveStart`
|
|
524
|
+
* @see `ResolveStart`
|
|
486
525
|
* @publicApi
|
|
487
526
|
*/
|
|
488
527
|
export declare class ChildActivationEnd {
|
|
@@ -585,10 +624,11 @@ export declare class DefaultUrlSerializer implements UrlSerializer {
|
|
|
585
624
|
/**
|
|
586
625
|
* A string of the form `path/to/file#exportName` that acts as a URL for a set of routes to load.
|
|
587
626
|
*
|
|
588
|
-
* @see `
|
|
627
|
+
* @see `loadChildrenCallback`
|
|
589
628
|
* @publicApi
|
|
590
|
-
* @deprecated
|
|
591
|
-
* `
|
|
629
|
+
* @deprecated The `string` form of `loadChildren` is deprecated in favor of the
|
|
630
|
+
* `LoadChildrenCallback` function which uses the ES dynamic `import()` expression.
|
|
631
|
+
* This offers a more natural and standards-based mechanism to dynamically
|
|
592
632
|
* load an ES module at runtime.
|
|
593
633
|
*/
|
|
594
634
|
export declare type DeprecatedLoadChildren = string;
|
|
@@ -608,8 +648,8 @@ export declare type DetachedRouteHandle = {};
|
|
|
608
648
|
/**
|
|
609
649
|
* Error handler that is invoked when a navigation error occurs.
|
|
610
650
|
*
|
|
611
|
-
* If the handler returns a value, the navigation
|
|
612
|
-
* If the handler throws an exception, the navigation
|
|
651
|
+
* If the handler returns a value, the navigation Promise is resolved with this value.
|
|
652
|
+
* If the handler throws an exception, the navigation Promise is rejected with
|
|
613
653
|
* the exception.
|
|
614
654
|
*
|
|
615
655
|
* @publicApi
|
|
@@ -619,24 +659,33 @@ declare type ErrorHandler = (error: any) => any;
|
|
|
619
659
|
/**
|
|
620
660
|
* Router events that allow you to track the lifecycle of the router.
|
|
621
661
|
*
|
|
622
|
-
* The
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
* -
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
*
|
|
662
|
+
* The events occur in the following sequence:
|
|
663
|
+
*
|
|
664
|
+
* * [NavigationStart](api/router/NavigationStart): Navigation starts.
|
|
665
|
+
* * [RouteConfigLoadStart](api/router/RouteConfigLoadStart): Before
|
|
666
|
+
* the router [lazy loads](/guide/router#lazy-loading) a route configuration.
|
|
667
|
+
* * [RouteConfigLoadEnd](api/router/RouteConfigLoadEnd): After a route has been lazy loaded.
|
|
668
|
+
* * [RoutesRecognized](api/router/RoutesRecognized): When the router parses the URL
|
|
669
|
+
* and the routes are recognized.
|
|
670
|
+
* * [GuardsCheckStart](api/router/GuardsCheckStart): When the router begins the *guards*
|
|
671
|
+
* phase of routing.
|
|
672
|
+
* * [ChildActivationStart](api/router/ChildActivationStart): When the router
|
|
673
|
+
* begins activating a route's children.
|
|
674
|
+
* * [ActivationStart](api/router/ActivationStart): When the router begins activating a route.
|
|
675
|
+
* * [GuardsCheckEnd](api/router/GuardsCheckEnd): When the router finishes the *guards*
|
|
676
|
+
* phase of routing successfully.
|
|
677
|
+
* * [ResolveStart](api/router/ResolveStart): When the router begins the *resolve*
|
|
678
|
+
* phase of routing.
|
|
679
|
+
* * [ResolveEnd](api/router/ResolveEnd): When the router finishes the *resolve*
|
|
680
|
+
* phase of routing successfuly.
|
|
681
|
+
* * [ChildActivationEnd](api/router/ChildActivationEnd): When the router finishes
|
|
682
|
+
* activating a route's children.
|
|
683
|
+
* * [ActivationEnd](api/router/ActivationStart): When the router finishes activating a route.
|
|
684
|
+
* * [NavigationEnd](api/router/NavigationEnd): When navigation ends successfully.
|
|
685
|
+
* * [NavigationCancel](api/router/NavigationCancel): When navigation is canceled.
|
|
686
|
+
* * [NavigationError](api/router/NavigationError): When navigation fails
|
|
687
|
+
* due to an unexpected error.
|
|
688
|
+
* * [Scroll](api/router/Scroll): When the user scrolls.
|
|
640
689
|
*
|
|
641
690
|
* @publicApi
|
|
642
691
|
*/
|
|
@@ -646,6 +695,9 @@ export declare type Event = RouterEvent | RouteConfigLoadStart | RouteConfigLoad
|
|
|
646
695
|
* A set of configuration options for a router module, provided in the
|
|
647
696
|
* `forRoot()` method.
|
|
648
697
|
*
|
|
698
|
+
* @see `forRoot()`
|
|
699
|
+
*
|
|
700
|
+
*
|
|
649
701
|
* @publicApi
|
|
650
702
|
*/
|
|
651
703
|
export declare interface ExtraOptions {
|
|
@@ -682,6 +734,9 @@ export declare interface ExtraOptions {
|
|
|
682
734
|
initialNavigation?: InitialNavigation;
|
|
683
735
|
/**
|
|
684
736
|
* A custom error handler for failed navigations.
|
|
737
|
+
* If the handler returns a value, the navigation Promise is resolved with this value.
|
|
738
|
+
* If the handler throws an exception, the navigation Promise is rejected with the exception.
|
|
739
|
+
*
|
|
685
740
|
*/
|
|
686
741
|
errorHandler?: ErrorHandler;
|
|
687
742
|
/**
|
|
@@ -808,6 +863,8 @@ export declare interface ExtraOptions {
|
|
|
808
863
|
/**
|
|
809
864
|
* An event triggered at the end of the Guard phase of routing.
|
|
810
865
|
*
|
|
866
|
+
* @see `GuardsCheckStart`
|
|
867
|
+
*
|
|
811
868
|
* @publicApi
|
|
812
869
|
*/
|
|
813
870
|
export declare class GuardsCheckEnd extends RouterEvent {
|
|
@@ -834,6 +891,8 @@ export declare class GuardsCheckEnd extends RouterEvent {
|
|
|
834
891
|
/**
|
|
835
892
|
* An event triggered at the start of the Guard phase of routing.
|
|
836
893
|
*
|
|
894
|
+
* @see `GuardsCheckEnd`
|
|
895
|
+
*
|
|
837
896
|
* @publicApi
|
|
838
897
|
*/
|
|
839
898
|
export declare class GuardsCheckStart extends RouterEvent {
|
|
@@ -864,13 +923,17 @@ export declare class GuardsCheckStart extends RouterEvent {
|
|
|
864
923
|
* the root component gets created. Use if there is a reason to have
|
|
865
924
|
* more control over when the router starts its initial navigation due to some complex
|
|
866
925
|
* initialization logic.
|
|
926
|
+
*
|
|
927
|
+
* The following values have been [deprecated](guide/releases#deprecation-practices) since v4,
|
|
928
|
+
* and should not be used for new applications.
|
|
929
|
+
*
|
|
867
930
|
* * 'legacy_enabled'- (Default, for compatibility.) The initial navigation starts after the root
|
|
868
931
|
* component has been created. The bootstrap is not blocked until the initial navigation is
|
|
869
|
-
* complete.
|
|
932
|
+
* complete.
|
|
870
933
|
* * 'legacy_disabled'- The initial navigation is not performed. The location listener is set up
|
|
871
|
-
* after the root component gets created.
|
|
872
|
-
* * `true` - same as 'legacy_enabled'.
|
|
873
|
-
* * `false` - same as 'legacy_disabled'.
|
|
934
|
+
* after the root component gets created.
|
|
935
|
+
* * `true` - same as 'legacy_enabled'.
|
|
936
|
+
* * `false` - same as 'legacy_disabled'.
|
|
874
937
|
*
|
|
875
938
|
* The 'legacy_enabled' and 'legacy_disabled' should not be used for new applications.
|
|
876
939
|
*
|
|
@@ -882,13 +945,12 @@ export declare type InitialNavigation = true | false | 'enabled' | 'disabled' |
|
|
|
882
945
|
|
|
883
946
|
/**
|
|
884
947
|
*
|
|
885
|
-
* A
|
|
886
|
-
* or a function that returns such a set.
|
|
948
|
+
* A function that returns a set of routes to load.
|
|
887
949
|
*
|
|
888
950
|
* The string form of `LoadChildren` is deprecated (see `DeprecatedLoadChildren`). The function
|
|
889
951
|
* form (`LoadChildrenCallback`) should be used instead.
|
|
890
952
|
*
|
|
891
|
-
* @see `
|
|
953
|
+
* @see `loadChildrenCallback`
|
|
892
954
|
* @publicApi
|
|
893
955
|
*/
|
|
894
956
|
export declare type LoadChildren = LoadChildrenCallback | DeprecatedLoadChildren;
|
|
@@ -896,8 +958,10 @@ export declare type LoadChildren = LoadChildrenCallback | DeprecatedLoadChildren
|
|
|
896
958
|
/**
|
|
897
959
|
*
|
|
898
960
|
* A function that is called to resolve a collection of lazy-loaded routes.
|
|
961
|
+
* Must be an arrow function of the following form:
|
|
962
|
+
* `() => import('...').then(mod => mod.MODULE)`
|
|
899
963
|
*
|
|
900
|
-
*
|
|
964
|
+
* For example:
|
|
901
965
|
*
|
|
902
966
|
* ```
|
|
903
967
|
* [{
|
|
@@ -906,23 +970,38 @@ export declare type LoadChildren = LoadChildrenCallback | DeprecatedLoadChildren
|
|
|
906
970
|
* }];
|
|
907
971
|
* ```
|
|
908
972
|
*
|
|
909
|
-
*
|
|
910
|
-
* `() => import('...').then(mod => mod.MODULE)`.
|
|
911
|
-
*
|
|
912
|
-
* @see `Route#loadChildren`.
|
|
973
|
+
* @see [Route.loadChildren](api/router/Route#loadChildren)
|
|
913
974
|
* @publicApi
|
|
914
975
|
*/
|
|
915
976
|
export declare type LoadChildrenCallback = () => Type<any> | NgModuleFactory<any> | Observable<Type<any>> | Promise<NgModuleFactory<any> | Type<any> | any>;
|
|
916
977
|
|
|
917
978
|
/**
|
|
918
|
-
* Information about a navigation operation.
|
|
919
|
-
* navigation object with the
|
|
979
|
+
* Information about a navigation operation.
|
|
980
|
+
* Retrieve the most recent navigation object with the
|
|
981
|
+
* [Router.getCurrentNavigation() method](api/router/Router#getcurrentnavigation) .
|
|
982
|
+
*
|
|
983
|
+
* * *id* : The unique identifier of the current navigation.
|
|
984
|
+
* * *initialUrl* : The target URL passed into the `Router#navigateByUrl()` call before navigation.
|
|
985
|
+
* This is the value before the router has parsed or applied redirects to it.
|
|
986
|
+
* * *extractedUrl* : The initial target URL after being parsed with `UrlSerializer.extract()`.
|
|
987
|
+
* * *finalUrl* : The extracted URL after redirects have been applied.
|
|
988
|
+
* This URL may not be available immediately, therefore this property can be `undefined`.
|
|
989
|
+
* It is guaranteed to be set after the `RoutesRecognized` event fires.
|
|
990
|
+
* * *trigger* : Identifies how this navigation was triggered.
|
|
991
|
+
* -- 'imperative'--Triggered by `router.navigateByUrl` or `router.navigate`.
|
|
992
|
+
* -- 'popstate'--Triggered by a popstate event.
|
|
993
|
+
* -- 'hashchange'--Triggered by a hashchange event.
|
|
994
|
+
* * *extras* : A `NavigationExtras` options object that controlled the strategy used for this
|
|
995
|
+
* navigation.
|
|
996
|
+
* * *previousNavigation* : The previously successful `Navigation` object. Only one previous
|
|
997
|
+
* navigation is available, therefore this previous `Navigation` object has a `null` value for its
|
|
998
|
+
* own `previousNavigation`.
|
|
920
999
|
*
|
|
921
1000
|
* @publicApi
|
|
922
1001
|
*/
|
|
923
1002
|
export declare type Navigation = {
|
|
924
1003
|
/**
|
|
925
|
-
* The
|
|
1004
|
+
* The unique identifier of the current navigation.
|
|
926
1005
|
*/
|
|
927
1006
|
id: number;
|
|
928
1007
|
/**
|
|
@@ -963,10 +1042,13 @@ export declare type Navigation = {
|
|
|
963
1042
|
|
|
964
1043
|
/**
|
|
965
1044
|
* An event triggered when a navigation is canceled, directly or indirectly.
|
|
966
|
-
*
|
|
967
|
-
* This can happen when a [route guard](guide/router-tutorial-toh#milestone-5-route-guards)
|
|
1045
|
+
* This can happen when a route guard
|
|
968
1046
|
* returns `false` or initiates a redirect by returning a `UrlTree`.
|
|
969
1047
|
*
|
|
1048
|
+
* @see `NavigationStart`
|
|
1049
|
+
* @see `NavigationEnd`
|
|
1050
|
+
* @see `NavigationError`
|
|
1051
|
+
*
|
|
970
1052
|
* @publicApi
|
|
971
1053
|
*/
|
|
972
1054
|
export declare class NavigationCancel extends RouterEvent {
|
|
@@ -986,6 +1068,10 @@ export declare class NavigationCancel extends RouterEvent {
|
|
|
986
1068
|
/**
|
|
987
1069
|
* An event triggered when a navigation ends successfully.
|
|
988
1070
|
*
|
|
1071
|
+
* @see `NavigationStart`
|
|
1072
|
+
* @see `NavigationCancel`
|
|
1073
|
+
* @see `NavigationError`
|
|
1074
|
+
*
|
|
989
1075
|
* @publicApi
|
|
990
1076
|
*/
|
|
991
1077
|
export declare class NavigationEnd extends RouterEvent {
|
|
@@ -1005,6 +1091,10 @@ export declare class NavigationEnd extends RouterEvent {
|
|
|
1005
1091
|
/**
|
|
1006
1092
|
* An event triggered when a navigation fails due to an unexpected error.
|
|
1007
1093
|
*
|
|
1094
|
+
* @see `NavigationStart`
|
|
1095
|
+
* @see `NavigationEnd`
|
|
1096
|
+
* @see `NavigationCancel`
|
|
1097
|
+
*
|
|
1008
1098
|
* @publicApi
|
|
1009
1099
|
*/
|
|
1010
1100
|
export declare class NavigationError extends RouterEvent {
|
|
@@ -1024,7 +1114,14 @@ export declare class NavigationError extends RouterEvent {
|
|
|
1024
1114
|
/**
|
|
1025
1115
|
* @description
|
|
1026
1116
|
*
|
|
1027
|
-
* Options that modify the navigation strategy.
|
|
1117
|
+
* Options that modify the `Router` navigation strategy.
|
|
1118
|
+
* Supply an object containing any of these properties to a `Router` navigation function to
|
|
1119
|
+
* control how the target URL should be constructed or interpreted.
|
|
1120
|
+
*
|
|
1121
|
+
* @see [Router.navigate() method](api/router/Router#navigate)
|
|
1122
|
+
* @see [Router.navigateByUrl() method](api/router/Router#navigatebyurl)
|
|
1123
|
+
* @see [Router.createUrlTree() method](api/router/Router#createurltree)
|
|
1124
|
+
* @see [Routing and Navigation guide](guide/router)
|
|
1028
1125
|
*
|
|
1029
1126
|
* @publicApi
|
|
1030
1127
|
*/
|
|
@@ -1092,13 +1189,24 @@ export declare interface NavigationExtras {
|
|
|
1092
1189
|
/**
|
|
1093
1190
|
* How to handle query parameters in the router link for the next navigation.
|
|
1094
1191
|
* One of:
|
|
1095
|
-
* * `merge` : Merge new with current parameters.
|
|
1096
1192
|
* * `preserve` : Preserve current parameters.
|
|
1193
|
+
* * `merge` : Merge new with current parameters.
|
|
1097
1194
|
*
|
|
1195
|
+
* The "preserve" option discards any new query params:
|
|
1098
1196
|
* ```
|
|
1099
|
-
* // from /
|
|
1100
|
-
* this.router.navigate(['/
|
|
1197
|
+
* // from /view1?page=1 to/view2?page=1
|
|
1198
|
+
* this.router.navigate(['/view2'], { queryParams: { page: 2 }, queryParamsHandling: "preserve"
|
|
1199
|
+
* });
|
|
1101
1200
|
* ```
|
|
1201
|
+
* The "merge" option appends new query params to the params from the current URL:
|
|
1202
|
+
* ```
|
|
1203
|
+
* // from /view1?page=1 to/view2?page=1&otherKey=2
|
|
1204
|
+
* this.router.navigate(['/view2'], { queryParams: { otherKey: 2 }, queryParamsHandling: "merge"
|
|
1205
|
+
* });
|
|
1206
|
+
* ```
|
|
1207
|
+
* In case of a key collision between current parameters and those in the `queryParams` object,
|
|
1208
|
+
* the new value is used.
|
|
1209
|
+
*
|
|
1102
1210
|
*/
|
|
1103
1211
|
queryParamsHandling?: QueryParamsHandling | null;
|
|
1104
1212
|
/**
|
|
@@ -1131,7 +1239,8 @@ export declare interface NavigationExtras {
|
|
|
1131
1239
|
/**
|
|
1132
1240
|
* Developer-defined state that can be passed to any navigation.
|
|
1133
1241
|
* Access this value through the `Navigation.extras` object
|
|
1134
|
-
* returned from
|
|
1242
|
+
* returned from the [Router.getCurrentNavigation()
|
|
1243
|
+
* method](api/router/Router#getcurrentnavigation) while a navigation is executing.
|
|
1135
1244
|
*
|
|
1136
1245
|
* After a navigation completes, the router writes an object containing this
|
|
1137
1246
|
* value together with a `navigationId` to `history.state`.
|
|
@@ -1140,6 +1249,7 @@ export declare interface NavigationExtras {
|
|
|
1140
1249
|
*
|
|
1141
1250
|
* Note that `history.state` does not pass an object equality test because
|
|
1142
1251
|
* the router adds the `navigationId` on each navigation.
|
|
1252
|
+
*
|
|
1143
1253
|
*/
|
|
1144
1254
|
state?: {
|
|
1145
1255
|
[k: string]: any;
|
|
@@ -1156,6 +1266,9 @@ export declare class NavigationStart extends RouterEvent {
|
|
|
1156
1266
|
* Identifies the call or event that triggered the navigation.
|
|
1157
1267
|
* An `imperative` trigger is a call to `router.navigateByUrl()` or `router.navigate()`.
|
|
1158
1268
|
*
|
|
1269
|
+
* @see `NavigationEnd`
|
|
1270
|
+
* @see `NavigationCancel`
|
|
1271
|
+
* @see `NavigationError`
|
|
1159
1272
|
*/
|
|
1160
1273
|
navigationTrigger?: 'imperative' | 'popstate' | 'hashchange';
|
|
1161
1274
|
/**
|
|
@@ -1338,8 +1451,11 @@ export declare type QueryParamsHandling = 'merge' | 'preserve' | '';
|
|
|
1338
1451
|
*
|
|
1339
1452
|
* Interface that classes can implement to be a data provider.
|
|
1340
1453
|
* A data provider class can be used with the router to resolve data during navigation.
|
|
1341
|
-
* The interface defines a `resolve()` method that
|
|
1342
|
-
* The router
|
|
1454
|
+
* The interface defines a `resolve()` method that is invoked when the navigation starts.
|
|
1455
|
+
* The router waits for the data to be resolved before the route is finally activated.
|
|
1456
|
+
*
|
|
1457
|
+
* The following example implements a `resolve()` method that retrieves the data
|
|
1458
|
+
* needed to activate the requested route.
|
|
1343
1459
|
*
|
|
1344
1460
|
* ```
|
|
1345
1461
|
* @Injectable({ providedIn: 'root' })
|
|
@@ -1353,7 +1469,13 @@ export declare type QueryParamsHandling = 'merge' | 'preserve' | '';
|
|
|
1353
1469
|
* return this.service.getHero(route.paramMap.get('id'));
|
|
1354
1470
|
* }
|
|
1355
1471
|
* }
|
|
1472
|
+
* ```
|
|
1356
1473
|
*
|
|
1474
|
+
* Here, the defined `resolve()` function is provided as part of the `Route` object
|
|
1475
|
+
* in the router configuration:
|
|
1476
|
+
*
|
|
1477
|
+
* ```
|
|
1478
|
+
|
|
1357
1479
|
* @NgModule({
|
|
1358
1480
|
* imports: [
|
|
1359
1481
|
* RouterModule.forRoot([
|
|
@@ -1371,7 +1493,7 @@ export declare type QueryParamsHandling = 'merge' | 'preserve' | '';
|
|
|
1371
1493
|
* export class AppRoutingModule {}
|
|
1372
1494
|
* ```
|
|
1373
1495
|
*
|
|
1374
|
-
* You can alternatively provide
|
|
1496
|
+
* You can alternatively provide an in-line function with the `resolve()` signature:
|
|
1375
1497
|
*
|
|
1376
1498
|
* ```
|
|
1377
1499
|
* export const myHero: Hero = {
|
|
@@ -1400,6 +1522,29 @@ export declare type QueryParamsHandling = 'merge' | 'preserve' | '';
|
|
|
1400
1522
|
* export class AppModule {}
|
|
1401
1523
|
* ```
|
|
1402
1524
|
*
|
|
1525
|
+
* @usageNotes
|
|
1526
|
+
*
|
|
1527
|
+
* When both guard and resolvers are specified, the resolvers are not executed until
|
|
1528
|
+
* all guards have run and succeeded.
|
|
1529
|
+
* For example, consider the following route configuration:
|
|
1530
|
+
*
|
|
1531
|
+
* ```
|
|
1532
|
+
* {
|
|
1533
|
+
* path: 'base'
|
|
1534
|
+
* canActivate: [BaseGuard],
|
|
1535
|
+
* resolve: {data: BaseDataResolver}
|
|
1536
|
+
* children: [
|
|
1537
|
+
* {
|
|
1538
|
+
* path: 'child',
|
|
1539
|
+
* guards: [ChildGuard],
|
|
1540
|
+
* component: ChildComponent,
|
|
1541
|
+
* resolve: {childData: ChildDataResolver}
|
|
1542
|
+
* }
|
|
1543
|
+
* ]
|
|
1544
|
+
* }
|
|
1545
|
+
* ```
|
|
1546
|
+
* The order of execution is: BaseGuard, ChildGuard, BaseDataResolver, ChildDataResolver.
|
|
1547
|
+
*
|
|
1403
1548
|
* @publicApi
|
|
1404
1549
|
*/
|
|
1405
1550
|
export declare interface Resolve<T> {
|
|
@@ -1447,6 +1592,8 @@ export declare class ResolveEnd extends RouterEvent {
|
|
|
1447
1592
|
* Runs in the "resolve" phase whether or not there is anything to resolve.
|
|
1448
1593
|
* In future, may change to only run when there are things to be resolved.
|
|
1449
1594
|
*
|
|
1595
|
+
* @see `ResolveEnd`
|
|
1596
|
+
*
|
|
1450
1597
|
* @publicApi
|
|
1451
1598
|
*/
|
|
1452
1599
|
export declare class ResolveStart extends RouterEvent {
|
|
@@ -1676,7 +1823,8 @@ export declare class ResolveStart extends RouterEvent {
|
|
|
1676
1823
|
*
|
|
1677
1824
|
* Lazy loading speeds up application load time by splitting the application
|
|
1678
1825
|
* into multiple bundles and loading them on demand.
|
|
1679
|
-
* To use lazy loading, provide the `loadChildren` property
|
|
1826
|
+
* To use lazy loading, provide the `loadChildren` property in the `Route` object,
|
|
1827
|
+
* instead of the `children` property.
|
|
1680
1828
|
*
|
|
1681
1829
|
* Given the following example route, the router will lazy load
|
|
1682
1830
|
* the associated module on demand using the browser native import system.
|
|
@@ -1775,7 +1923,7 @@ export declare interface Route {
|
|
|
1775
1923
|
*/
|
|
1776
1924
|
children?: Routes;
|
|
1777
1925
|
/**
|
|
1778
|
-
*
|
|
1926
|
+
* An object specifying lazy-loaded child routes.
|
|
1779
1927
|
*/
|
|
1780
1928
|
loadChildren?: LoadChildren;
|
|
1781
1929
|
/**
|
|
@@ -1791,6 +1939,8 @@ export declare interface Route {
|
|
|
1791
1939
|
/**
|
|
1792
1940
|
* An event triggered when a route has been lazy loaded.
|
|
1793
1941
|
*
|
|
1942
|
+
* @see `RouteConfigLoadStart`
|
|
1943
|
+
*
|
|
1794
1944
|
* @publicApi
|
|
1795
1945
|
*/
|
|
1796
1946
|
export declare class RouteConfigLoadEnd {
|
|
@@ -1805,6 +1955,8 @@ export declare class RouteConfigLoadEnd {
|
|
|
1805
1955
|
/**
|
|
1806
1956
|
* An event triggered before lazy loading a route configuration.
|
|
1807
1957
|
*
|
|
1958
|
+
* @see `RouteConfigLoadEnd`
|
|
1959
|
+
*
|
|
1808
1960
|
* @publicApi
|
|
1809
1961
|
*/
|
|
1810
1962
|
export declare class RouteConfigLoadStart {
|
|
@@ -1819,7 +1971,7 @@ export declare class RouteConfigLoadStart {
|
|
|
1819
1971
|
/**
|
|
1820
1972
|
* @description
|
|
1821
1973
|
*
|
|
1822
|
-
* A service that provides navigation and URL manipulation capabilities.
|
|
1974
|
+
* A service that provides navigation among views and URL manipulation capabilities.
|
|
1823
1975
|
*
|
|
1824
1976
|
* @see `Route`.
|
|
1825
1977
|
* @see [Routing and Navigation Guide](guide/router).
|
|
@@ -1930,7 +2082,7 @@ export declare class Router {
|
|
|
1930
2082
|
/** The current Navigation object if one exists */
|
|
1931
2083
|
getCurrentNavigation(): Navigation | null;
|
|
1932
2084
|
/**
|
|
1933
|
-
* Resets the configuration used for navigation and generating links.
|
|
2085
|
+
* Resets the route configuration used for navigation and generating links.
|
|
1934
2086
|
*
|
|
1935
2087
|
* @param config The route array for the new configuration.
|
|
1936
2088
|
*
|
|
@@ -1951,14 +2103,15 @@ export declare class Router {
|
|
|
1951
2103
|
/** Disposes of the router. */
|
|
1952
2104
|
dispose(): void;
|
|
1953
2105
|
/**
|
|
1954
|
-
*
|
|
1955
|
-
*
|
|
1956
|
-
* When given an activated route, applies the given commands starting from the route.
|
|
1957
|
-
* Otherwise, applies the given command starting from the root.
|
|
2106
|
+
* Appends URL segments to the current URL tree to create a new URL tree.
|
|
1958
2107
|
*
|
|
1959
|
-
* @param commands An array of
|
|
2108
|
+
* @param commands An array of URL fragments with which to construct the new URL tree.
|
|
2109
|
+
* If the path is static, can be the literal URL string. For a dynamic path, pass an array of path
|
|
2110
|
+
* segments, followed by the parameters for each segment.
|
|
2111
|
+
* The fragments are applied to the current URL tree or the one provided in the `relativeTo`
|
|
2112
|
+
* property of the options object, if supplied.
|
|
1960
2113
|
* @param navigationExtras Options that control the navigation strategy. This function
|
|
1961
|
-
* only
|
|
2114
|
+
* only uses properties in `NavigationExtras` that would change the provided URL.
|
|
1962
2115
|
* @returns The new URL tree.
|
|
1963
2116
|
*
|
|
1964
2117
|
* @usageNotes
|
|
@@ -1997,9 +2150,10 @@ export declare class Router {
|
|
|
1997
2150
|
*/
|
|
1998
2151
|
createUrlTree(commands: any[], navigationExtras?: NavigationExtras): UrlTree;
|
|
1999
2152
|
/**
|
|
2000
|
-
*
|
|
2153
|
+
* Navigates to a view using an absolute route path.
|
|
2001
2154
|
*
|
|
2002
|
-
* @param url An absolute
|
|
2155
|
+
* @param url An absolute path for a defined route. The function does not apply any delta to the
|
|
2156
|
+
* current URL.
|
|
2003
2157
|
* @param extras An object containing properties that modify the navigation strategy.
|
|
2004
2158
|
* The function ignores any properties in the `NavigationExtras` that would change the
|
|
2005
2159
|
* provided URL.
|
|
@@ -2009,6 +2163,8 @@ export declare class Router {
|
|
|
2009
2163
|
*
|
|
2010
2164
|
* @usageNotes
|
|
2011
2165
|
*
|
|
2166
|
+
* The following calls request navigation to an absolute path.
|
|
2167
|
+
*
|
|
2012
2168
|
* ```
|
|
2013
2169
|
* router.navigateByUrl("/team/33/user/11");
|
|
2014
2170
|
*
|
|
@@ -2016,34 +2172,39 @@ export declare class Router {
|
|
|
2016
2172
|
* router.navigateByUrl("/team/33/user/11", { skipLocationChange: true });
|
|
2017
2173
|
* ```
|
|
2018
2174
|
*
|
|
2175
|
+
* @see [Routing and Navigation guide](guide/router)
|
|
2176
|
+
*
|
|
2019
2177
|
*/
|
|
2020
2178
|
navigateByUrl(url: string | UrlTree, extras?: NavigationExtras): Promise<boolean>;
|
|
2021
2179
|
/**
|
|
2022
2180
|
* Navigate based on the provided array of commands and a starting point.
|
|
2023
2181
|
* If no starting route is provided, the navigation is absolute.
|
|
2024
2182
|
*
|
|
2025
|
-
*
|
|
2026
|
-
*
|
|
2027
|
-
*
|
|
2028
|
-
*
|
|
2183
|
+
* @param commands An array of URL fragments with which to construct the target URL.
|
|
2184
|
+
* If the path is static, can be the literal URL string. For a dynamic path, pass an array of path
|
|
2185
|
+
* segments, followed by the parameters for each segment.
|
|
2186
|
+
* The fragments are applied to the current URL or the one provided in the `relativeTo` property
|
|
2187
|
+
* of the options object, if supplied.
|
|
2188
|
+
* @param extras An options object that determines how the URL should be constructed or
|
|
2189
|
+
* interpreted.
|
|
2190
|
+
*
|
|
2191
|
+
* @returns A Promise that resolves to `true` when navigation succeeds, to `false` when navigation
|
|
2192
|
+
* fails,
|
|
2193
|
+
* or is rejected on error.
|
|
2029
2194
|
*
|
|
2030
2195
|
* @usageNotes
|
|
2031
2196
|
*
|
|
2197
|
+
* The following calls request navigation to a dynamic route path relative to the current URL.
|
|
2198
|
+
*
|
|
2032
2199
|
* ```
|
|
2033
2200
|
* router.navigate(['team', 33, 'user', 11], {relativeTo: route});
|
|
2034
2201
|
*
|
|
2035
|
-
* // Navigate without updating the URL
|
|
2202
|
+
* // Navigate without updating the URL, overriding the default behavior
|
|
2036
2203
|
* router.navigate(['team', 33, 'user', 11], {relativeTo: route, skipLocationChange: true});
|
|
2037
2204
|
* ```
|
|
2038
2205
|
*
|
|
2039
|
-
*
|
|
2040
|
-
* or the one provided in the `relativeTo` property of the second parameter (the
|
|
2041
|
-
* `NavigationExtras`).
|
|
2206
|
+
* @see [Routing and Navigation guide](guide/router)
|
|
2042
2207
|
*
|
|
2043
|
-
* In order to affect this browser's `history.state` entry, the `state`
|
|
2044
|
-
* parameter can be passed. This must be an object because the router
|
|
2045
|
-
* will add the `navigationId` property to this object before creating
|
|
2046
|
-
* the new history item.
|
|
2047
2208
|
*/
|
|
2048
2209
|
navigate(commands: any[], extras?: NavigationExtras): Promise<boolean>;
|
|
2049
2210
|
/** Serializes a `UrlTree` into a string */
|
|
@@ -2103,7 +2264,7 @@ export declare abstract class RouteReuseStrategy {
|
|
|
2103
2264
|
* Base for events the router goes through, as opposed to events tied to a specific
|
|
2104
2265
|
* route. Fired one time for any given navigation.
|
|
2105
2266
|
*
|
|
2106
|
-
*
|
|
2267
|
+
* The following code shows how a class subscribes to router events.
|
|
2107
2268
|
*
|
|
2108
2269
|
* ```ts
|
|
2109
2270
|
* class MyService {
|
|
@@ -2118,6 +2279,7 @@ export declare abstract class RouteReuseStrategy {
|
|
|
2118
2279
|
* ```
|
|
2119
2280
|
*
|
|
2120
2281
|
* @see `Event`
|
|
2282
|
+
* @see [Router events summary](guide/router#router-events)
|
|
2121
2283
|
* @publicApi
|
|
2122
2284
|
*/
|
|
2123
2285
|
export declare class RouterEvent {
|
|
@@ -2463,53 +2625,23 @@ export declare class RouterLinkWithHref implements OnChanges, OnDestroy {
|
|
|
2463
2625
|
}
|
|
2464
2626
|
|
|
2465
2627
|
/**
|
|
2466
|
-
* @usageNotes
|
|
2467
|
-
*
|
|
2468
|
-
* RouterModule can be imported multiple times: once per lazily-loaded bundle.
|
|
2469
|
-
* Since the router deals with a global shared resource--location, we cannot have
|
|
2470
|
-
* more than one router service active.
|
|
2471
|
-
*
|
|
2472
|
-
* That is why there are two ways to create the module: `RouterModule.forRoot` and
|
|
2473
|
-
* `RouterModule.forChild`.
|
|
2474
|
-
*
|
|
2475
|
-
* * `forRoot` creates a module that contains all the directives, the given routes, and the router
|
|
2476
|
-
* service itself.
|
|
2477
|
-
* * `forChild` creates a module that contains all the directives and the given routes, but does not
|
|
2478
|
-
* include the router service.
|
|
2479
|
-
*
|
|
2480
|
-
* When registered at the root, the module should be used as follows
|
|
2481
|
-
*
|
|
2482
|
-
* ```
|
|
2483
|
-
* @NgModule({
|
|
2484
|
-
* imports: [RouterModule.forRoot(ROUTES)]
|
|
2485
|
-
* })
|
|
2486
|
-
* class MyNgModule {}
|
|
2487
|
-
* ```
|
|
2488
|
-
*
|
|
2489
|
-
* For submodules and lazy loaded submodules the module should be used as follows:
|
|
2490
|
-
*
|
|
2491
|
-
* ```
|
|
2492
|
-
* @NgModule({
|
|
2493
|
-
* imports: [RouterModule.forChild(ROUTES)]
|
|
2494
|
-
* })
|
|
2495
|
-
* class MyNgModule {}
|
|
2496
|
-
* ```
|
|
2497
|
-
*
|
|
2498
2628
|
* @description
|
|
2499
2629
|
*
|
|
2500
|
-
* Adds
|
|
2630
|
+
* Adds directives and providers for in-app navigation among views defined in an application.
|
|
2631
|
+
* Use the Angular `Router` service to declaratively specify application states and manage state
|
|
2632
|
+
* transitions.
|
|
2501
2633
|
*
|
|
2502
|
-
*
|
|
2503
|
-
*
|
|
2504
|
-
*
|
|
2505
|
-
* Doing this transparently is not trivial.
|
|
2634
|
+
* You can import this NgModule multiple times, once for each lazy-loaded bundle.
|
|
2635
|
+
* However, only one `Router` service can be active.
|
|
2636
|
+
* To ensure this, there are two ways to register routes when importing this module:
|
|
2506
2637
|
*
|
|
2507
|
-
* The
|
|
2508
|
-
*
|
|
2509
|
-
*
|
|
2638
|
+
* * The `forRoot()` method creates an `NgModule` that contains all the directives, the given
|
|
2639
|
+
* routes, and the `Router` service itself.
|
|
2640
|
+
* * The `forChild()` method creates an `NgModule` that contains all the directives and the given
|
|
2641
|
+
* routes, but does not include the `Router` service.
|
|
2510
2642
|
*
|
|
2511
|
-
* @see [Routing and Navigation](guide/router
|
|
2512
|
-
* overview of how the
|
|
2643
|
+
* @see [Routing and Navigation guide](guide/router) for an
|
|
2644
|
+
* overview of how the `Router` service should be used.
|
|
2513
2645
|
*
|
|
2514
2646
|
* @publicApi
|
|
2515
2647
|
*/
|
|
@@ -2519,13 +2651,36 @@ export declare class RouterModule {
|
|
|
2519
2651
|
* Creates and configures a module with all the router providers and directives.
|
|
2520
2652
|
* Optionally sets up an application listener to perform an initial navigation.
|
|
2521
2653
|
*
|
|
2654
|
+
* When registering the NgModule at the root, import as follows:
|
|
2655
|
+
*
|
|
2656
|
+
* ```
|
|
2657
|
+
* @NgModule({
|
|
2658
|
+
* imports: [RouterModule.forRoot(ROUTES)]
|
|
2659
|
+
* })
|
|
2660
|
+
* class MyNgModule {}
|
|
2661
|
+
* ```
|
|
2662
|
+
*
|
|
2522
2663
|
* @param routes An array of `Route` objects that define the navigation paths for the application.
|
|
2523
2664
|
* @param config An `ExtraOptions` configuration object that controls how navigation is performed.
|
|
2524
|
-
* @return The new
|
|
2665
|
+
* @return The new `NgModule`.
|
|
2666
|
+
*
|
|
2525
2667
|
*/
|
|
2526
2668
|
static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders<RouterModule>;
|
|
2527
2669
|
/**
|
|
2528
|
-
* Creates a module with all the router directives and a provider registering routes
|
|
2670
|
+
* Creates a module with all the router directives and a provider registering routes,
|
|
2671
|
+
* without creating a new Router service.
|
|
2672
|
+
* When registering for submodules and lazy-loaded submodules, create the NgModule as follows:
|
|
2673
|
+
*
|
|
2674
|
+
* ```
|
|
2675
|
+
* @NgModule({
|
|
2676
|
+
* imports: [RouterModule.forChild(ROUTES)]
|
|
2677
|
+
* })
|
|
2678
|
+
* class MyNgModule {}
|
|
2679
|
+
* ```
|
|
2680
|
+
*
|
|
2681
|
+
* @param routes An array of `Route` objects that define the navigation paths for the submodule.
|
|
2682
|
+
* @return The new NgModule.
|
|
2683
|
+
*
|
|
2529
2684
|
*/
|
|
2530
2685
|
static forChild(routes: Routes): ModuleWithProviders<RouterModule>;
|
|
2531
2686
|
}
|
|
@@ -2621,7 +2776,8 @@ export declare class RouterPreloader implements OnDestroy {
|
|
|
2621
2776
|
* and the resolved data.
|
|
2622
2777
|
* Use the `ActivatedRoute` properties to traverse the tree from any node.
|
|
2623
2778
|
*
|
|
2624
|
-
*
|
|
2779
|
+
* The following fragment shows how a component gets the root node
|
|
2780
|
+
* of the current state to establish its own route tree:
|
|
2625
2781
|
*
|
|
2626
2782
|
* ```
|
|
2627
2783
|
* @Component({templateUrl:'template.html'})
|
|
@@ -2637,6 +2793,7 @@ export declare class RouterPreloader implements OnDestroy {
|
|
|
2637
2793
|
* ```
|
|
2638
2794
|
*
|
|
2639
2795
|
* @see `ActivatedRoute`
|
|
2796
|
+
* @see [Getting route information](guide/router#getting-route-information)
|
|
2640
2797
|
*
|
|
2641
2798
|
* @publicApi
|
|
2642
2799
|
*/
|
|
@@ -2654,8 +2811,8 @@ export declare class RouterState extends ɵangular_packages_router_router_m<Acti
|
|
|
2654
2811
|
* This is a tree of activated route snapshots. Every node in this tree knows about
|
|
2655
2812
|
* the "consumed" URL segments, the extracted parameters, and the resolved data.
|
|
2656
2813
|
*
|
|
2657
|
-
*
|
|
2658
|
-
*
|
|
2814
|
+
* The following example shows how a component is initialized with information
|
|
2815
|
+
* from the snapshot of the root node's state at the time of creation.
|
|
2659
2816
|
*
|
|
2660
2817
|
* ```
|
|
2661
2818
|
* @Component({templateUrl:'template.html'})
|
|
@@ -2693,12 +2850,13 @@ export declare const ROUTES: InjectionToken<Route[][]>;
|
|
|
2693
2850
|
*
|
|
2694
2851
|
* @see `Route`
|
|
2695
2852
|
* @see `Router`
|
|
2853
|
+
* @see [Router configuration guide](guide/router#configuration)
|
|
2696
2854
|
* @publicApi
|
|
2697
2855
|
*/
|
|
2698
2856
|
export declare type Routes = Route[];
|
|
2699
2857
|
|
|
2700
2858
|
/**
|
|
2701
|
-
*An event triggered when routes are recognized.
|
|
2859
|
+
* An event triggered when routes are recognized.
|
|
2702
2860
|
*
|
|
2703
2861
|
* @publicApi
|
|
2704
2862
|
*/
|
|
@@ -2724,7 +2882,7 @@ export declare class RoutesRecognized extends RouterEvent {
|
|
|
2724
2882
|
*
|
|
2725
2883
|
* A policy for when to run guards and resolvers on a route.
|
|
2726
2884
|
*
|
|
2727
|
-
* @see
|
|
2885
|
+
* @see [Route.runGuardsAndResolvers](api/router/Route#runGuardsAndResolvers)
|
|
2728
2886
|
* @publicApi
|
|
2729
2887
|
*/
|
|
2730
2888
|
export declare type RunGuardsAndResolvers = 'pathParamsChange' | 'pathParamsOrQueryParamsChange' | 'paramsChange' | 'paramsOrQueryParamsChange' | 'always' | ((from: ActivatedRouteSnapshot, to: ActivatedRouteSnapshot) => boolean);
|
|
@@ -2784,14 +2942,12 @@ export declare abstract class UrlHandlingStrategy {
|
|
|
2784
2942
|
* for `Route.matcher` when a combination of `path` and `pathMatch`
|
|
2785
2943
|
* is not expressive enough. Cannot be used together with `path` and `pathMatch`.
|
|
2786
2944
|
*
|
|
2787
|
-
*
|
|
2788
|
-
*
|
|
2789
|
-
*
|
|
2790
|
-
*
|
|
2791
|
-
*
|
|
2792
|
-
* @usageNotes
|
|
2945
|
+
* The function takes the following arguments and returns a `UrlMatchResult` object.
|
|
2946
|
+
* * *segments* : An array of URL segments.
|
|
2947
|
+
* * *group* : A segment group.
|
|
2948
|
+
* * *route* : The route to match against.
|
|
2793
2949
|
*
|
|
2794
|
-
* The following
|
|
2950
|
+
* The following example implementation matches HTML files.
|
|
2795
2951
|
*
|
|
2796
2952
|
* ```
|
|
2797
2953
|
* export function htmlFiles(url: UrlSegment[]) {
|