@angular/router 18.0.0-next.3 → 18.0.0-next.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.
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @license Angular v18.0.0-next.3
3
- * (c) 2010-2022 Google LLC. https://angular.io/
2
+ * @license Angular v18.0.0-next.5
3
+ * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
@@ -59,16 +59,16 @@ class RouterTestingModule {
59
59
  ],
60
60
  };
61
61
  }
62
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0-next.3", ngImport: i0, type: RouterTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
63
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.0-next.3", ngImport: i0, type: RouterTestingModule, exports: [RouterModule] }); }
64
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.0-next.3", ngImport: i0, type: RouterTestingModule, providers: [
62
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0-next.5", ngImport: i0, type: RouterTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
63
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.0-next.5", ngImport: i0, type: RouterTestingModule, exports: [RouterModule] }); }
64
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.0-next.5", ngImport: i0, type: RouterTestingModule, providers: [
65
65
  ɵROUTER_PROVIDERS,
66
66
  provideLocationMocks(),
67
67
  withPreloading(NoPreloading).ɵproviders,
68
68
  { provide: ROUTES, multi: true, useValue: [] },
69
69
  ], imports: [RouterModule] }); }
70
70
  }
71
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0-next.3", ngImport: i0, type: RouterTestingModule, decorators: [{
71
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0-next.5", ngImport: i0, type: RouterTestingModule, decorators: [{
72
72
  type: NgModule,
73
73
  args: [{
74
74
  exports: [RouterModule],
@@ -97,18 +97,18 @@ class RootFixtureService {
97
97
  this.fixture.detectChanges();
98
98
  return this.fixture;
99
99
  }
100
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0-next.3", ngImport: i0, type: RootFixtureService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
101
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.0-next.3", ngImport: i0, type: RootFixtureService, providedIn: 'root' }); }
100
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0-next.5", ngImport: i0, type: RootFixtureService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
101
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.0-next.5", ngImport: i0, type: RootFixtureService, providedIn: 'root' }); }
102
102
  }
103
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0-next.3", ngImport: i0, type: RootFixtureService, decorators: [{
103
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0-next.5", ngImport: i0, type: RootFixtureService, decorators: [{
104
104
  type: Injectable,
105
105
  args: [{ providedIn: 'root' }]
106
106
  }] });
107
107
  class RootCmp {
108
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0-next.3", ngImport: i0, type: RootCmp, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
109
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.0-next.3", type: RootCmp, isStandalone: true, selector: "ng-component", viewQueries: [{ propertyName: "outlet", first: true, predicate: RouterOutlet, descendants: true }], ngImport: i0, template: '<router-outlet></router-outlet>', isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] }); }
108
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0-next.5", ngImport: i0, type: RootCmp, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
109
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.0-next.5", type: RootCmp, isStandalone: true, selector: "ng-component", viewQueries: [{ propertyName: "outlet", first: true, predicate: RouterOutlet, descendants: true }], ngImport: i0, template: '<router-outlet></router-outlet>', isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] }); }
110
110
  }
111
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0-next.3", ngImport: i0, type: RootCmp, decorators: [{
111
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0-next.5", ngImport: i0, type: RootCmp, decorators: [{
112
112
  type: Component,
113
113
  args: [{
114
114
  standalone: true,
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @license Angular v18.0.0-next.3
3
- * (c) 2010-2022 Google LLC. https://angular.io/
2
+ * @license Angular v18.0.0-next.5
3
+ * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @license Angular v18.0.0-next.3
3
- * (c) 2010-2022 Google LLC. https://angular.io/
2
+ * @license Angular v18.0.0-next.5
3
+ * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
@@ -48,7 +48,7 @@ import { Version } from '@angular/core';
48
48
  * {@example router/activated-route/module.ts region="activated-route"
49
49
  * header="activated-route.component.ts"}
50
50
  *
51
- * @see [Getting route information](guide/router#getting-route-information)
51
+ * @see [Getting route information](guide/routing/common-router-tasks#getting-route-information)
52
52
  *
53
53
  * @publicApi
54
54
  */
@@ -401,12 +401,44 @@ export declare type CanActivateChildFn = (childRoute: ActivatedRouteSnapshot, st
401
401
  * The following example implements and uses a `CanActivateFn` that checks whether the
402
402
  * current user has permission to activate the requested route.
403
403
  *
404
- * {@example router/route_functional_guards.ts region="CanActivateFn"}
405
-
404
+ * ```ts
405
+ * @Injectable()
406
+ * class UserToken {}
407
+ *
408
+ * @Injectable()
409
+ * class PermissionsService {
410
+ * canActivate(currentUser: UserToken, userId: string): boolean {
411
+ * return true;
412
+ * }
413
+ * canMatch(currentUser: UserToken): boolean {
414
+ * return true;
415
+ * }
416
+ * }
417
+ *
418
+ * const canActivateTeam: CanActivateFn = (
419
+ * route: ActivatedRouteSnapshot,
420
+ * state: RouterStateSnapshot,
421
+ * ) => {
422
+ * return inject(PermissionsService).canActivate(inject(UserToken), route.params['id']);
423
+ * };
424
+ * ```
425
+ *
406
426
  * Here, the defined guard function is provided as part of the `Route` object
407
427
  * in the router configuration:
408
-
409
- * {@example router/route_functional_guards.ts region="CanActivateFnInRoute"}
428
+ *
429
+ * ```ts
430
+ * bootstrapApplication(App, {
431
+ * providers: [
432
+ * provideRouter([
433
+ * {
434
+ * path: 'team/:id',
435
+ * component: TeamComponent,
436
+ * canActivate: [canActivateTeam],
437
+ * },
438
+ * ]),
439
+ * ],
440
+ * });
441
+ * ```
410
442
  *
411
443
  * @publicApi
412
444
  * @see {@link Route}
@@ -942,7 +974,7 @@ export declare type EnabledBlockingInitialNavigationFeature = RouterFeature<Rout
942
974
  *
943
975
  * * [NavigationStart](api/router/NavigationStart): Navigation starts.
944
976
  * * [RouteConfigLoadStart](api/router/RouteConfigLoadStart): Before
945
- * the router [lazy loads](/guide/router#lazy-loading) a route configuration.
977
+ * the router [lazy loads](guide/routing/common-router-tasks#lazy-loading) a route configuration.
946
978
  * * [RouteConfigLoadEnd](api/router/RouteConfigLoadEnd): After a route has been lazy loaded.
947
979
  * * [RoutesRecognized](api/router/RoutesRecognized): When the router parses the URL
948
980
  * and the routes are recognized.
@@ -1073,7 +1105,7 @@ export declare interface ExtraOptions extends InMemoryScrollingOptions, RouterCo
1073
1105
  /**
1074
1106
  * The supported types that can be returned from a `Router` guard.
1075
1107
  *
1076
- * @see [Routing tutorial](guide/router-tutorial-toh#milestone-5-route-guards)
1108
+ * @see [Routing guide](guide/routing/common-router-tasks#preventing-unauthorized-access)
1077
1109
  * @publicApi
1078
1110
  */
1079
1111
  export declare type GuardResult = boolean | UrlTree | RedirectCommand;
@@ -1503,7 +1535,7 @@ export declare interface Navigation {
1503
1535
  *
1504
1536
  * @see {@link Router#navigate}
1505
1537
  * @see {@link Router#navigateByUrl}
1506
- * @see [Routing and Navigation guide](guide/router)
1538
+ * @see [Routing and Navigation guide](guide/routing/common-router-tasks)
1507
1539
  *
1508
1540
  * @publicApi
1509
1541
  */
@@ -1732,7 +1764,7 @@ export declare type NavigationErrorHandlerFeature = RouterFeature<RouterFeatureK
1732
1764
  * @see {@link Router#navigate}
1733
1765
  * @see {@link Router#navigateByUrl}
1734
1766
  * @see {@link Router#createurltree}
1735
- * @see [Routing and Navigation guide](guide/router)
1767
+ * @see [Routing and Navigation guide](guide/routing/common-router-tasks)
1736
1768
  * @see {@link UrlCreationOptions}
1737
1769
  * @see {@link NavigationBehaviorOptions}
1738
1770
  *
@@ -2090,7 +2122,29 @@ export declare type QueryParamsHandling = 'merge' | 'preserve' | '';
2090
2122
  * navigation should go to and the optional `navigationBehaviorOptions` can provide more information
2091
2123
  * about _how_ to perform the navigation.
2092
2124
  *
2093
- * @see [Routing tutorial](guide/router-tutorial-toh#milestone-5-route-guards)
2125
+ * ```ts
2126
+ * const route: Route = {
2127
+ * path: "user/:userId",
2128
+ * component: User,
2129
+ * canActivate: [
2130
+ * () => {
2131
+ * const router = inject(Router);
2132
+ * const authService = inject(AuthenticationService);
2133
+ *
2134
+ * if (!authService.isLoggedIn()) {
2135
+ * const loginPath = router.parseUrl("/login");
2136
+ * return new RedirectCommand(loginPath, {
2137
+ * skipLocationChange: "true",
2138
+ * });
2139
+ * }
2140
+ *
2141
+ * return true;
2142
+ * },
2143
+ * ],
2144
+ * };
2145
+ * ```
2146
+ * @see [Routing guide](guide/routing/common-router-tasks#preventing-unauthorized-access)
2147
+ *
2094
2148
  * @publicApi
2095
2149
  */
2096
2150
  export declare class RedirectCommand {
@@ -2260,20 +2314,81 @@ export declare class ResolveEnd extends RouterEvent {
2260
2314
 
2261
2315
  /**
2262
2316
  * Function type definition for a data provider.
2263
-
2317
+ *
2264
2318
  * A data provider can be used with the router to resolve data during navigation.
2265
2319
  * The router waits for the data to be resolved before the route is finally activated.
2266
2320
  *
2321
+ * A resolver can also redirect a `RedirectCommand` and the Angular router will use
2322
+ * it to redirect the current navigation to the new destination.
2323
+ *
2324
+ * @usageNotes
2325
+ *
2267
2326
  * The following example implements a function that retrieves the data
2268
2327
  * needed to activate the requested route.
2269
2328
  *
2270
- * {@example router/route_functional_guards.ts region="ResolveFn"}
2329
+ * ```ts
2330
+ * interface Hero {
2331
+ * name: string;
2332
+ * }
2333
+ * @Injectable()
2334
+ * export class HeroService {
2335
+ * getHero(id: string) {
2336
+ * return {name: `Superman-${id}`};
2337
+ * }
2338
+ * }
2339
+ *
2340
+ * export const heroResolver: ResolveFn<Hero> = (
2341
+ * route: ActivatedRouteSnapshot,
2342
+ * state: RouterStateSnapshot,
2343
+ * ) => {
2344
+ * return inject(HeroService).getHero(route.paramMap.get('id')!);
2345
+ * };
2346
+ *
2347
+ * bootstrapApplication(App, {
2348
+ * providers: [
2349
+ * provideRouter([
2350
+ * {
2351
+ * path: 'detail/:id',
2352
+ * component: HeroDetailComponent,
2353
+ * resolve: {hero: heroResolver},
2354
+ * },
2355
+ * ]),
2356
+ * ],
2357
+ * });
2358
+ * ```
2271
2359
  *
2272
2360
  * And you can access to your resolved data from `HeroComponent`:
2273
2361
  *
2274
- * {@example router/route_functional_guards.ts region="ResolveDataUse"}
2362
+ * ```ts
2363
+ * @Component({template: ''})
2364
+ * export class HeroDetailComponent {
2365
+ * private activatedRoute = inject(ActivatedRoute);
2275
2366
  *
2276
- * @usageNotes
2367
+ * ngOnInit() {
2368
+ * this.activatedRoute.data.subscribe(({hero}) => {
2369
+ * // do something with your resolved data ...
2370
+ * });
2371
+ * }
2372
+ * }
2373
+ * ```
2374
+ *
2375
+ * If resolved data cannot be retrieved, you may want to redirect the user
2376
+ * to a new page instead:
2377
+ *
2378
+ * ```ts
2379
+ * export const heroResolver: ResolveFn<Hero> = async (
2380
+ * route: ActivatedRouteSnapshot,
2381
+ * state: RouterStateSnapshot,
2382
+ * ) => {
2383
+ * const router = inject(Router);
2384
+ * const heroService = inject(HeroService);
2385
+ * try {
2386
+ * return await heroService.getHero(route.paramMap.get('id')!);
2387
+ * } catch {
2388
+ * return new RedirectCommand(router.parseUrl('/404'));
2389
+ * }
2390
+ * };
2391
+ * ```
2277
2392
  *
2278
2393
  * When both guard and resolvers are specified, the resolvers are not executed until
2279
2394
  * all guards have run and succeeded.
@@ -2338,7 +2453,7 @@ export declare class ResolveStart extends RouterEvent {
2338
2453
  * Supports static, parameterized, redirect, and wildcard routes, as well as
2339
2454
  * custom route data and resolve methods.
2340
2455
  *
2341
- * For detailed usage information, see the [Routing Guide](guide/router).
2456
+ * For detailed usage information, see the [Routing Guide](guide/routing/common-router-tasks).
2342
2457
  *
2343
2458
  * @usageNotes
2344
2459
  *
@@ -2776,7 +2891,7 @@ declare class RoutedComponentInputBinder {
2776
2891
  * A service that provides navigation among views and URL manipulation capabilities.
2777
2892
  *
2778
2893
  * @see {@link Route}
2779
- * @see [Routing and Navigation Guide](guide/router).
2894
+ * @see [Routing and Navigation Guide](guide/routing/common-router-tasks).
2780
2895
  *
2781
2896
  * @ngModule RouterModule
2782
2897
  *
@@ -2787,7 +2902,6 @@ export declare class Router {
2787
2902
  private get rawUrlTree();
2788
2903
  private disposed;
2789
2904
  private nonRouterCurrentEntryChangeSubscription?;
2790
- private isNgZoneEnabled;
2791
2905
  private readonly console;
2792
2906
  private readonly stateManager;
2793
2907
  private readonly options;
@@ -2973,7 +3087,7 @@ export declare class Router {
2973
3087
  * router.navigateByUrl("/team/33/user/11", { skipLocationChange: true });
2974
3088
  * ```
2975
3089
  *
2976
- * @see [Routing and Navigation guide](guide/router)
3090
+ * @see [Routing and Navigation guide](guide/routing/common-router-tasks)
2977
3091
  *
2978
3092
  */
2979
3093
  navigateByUrl(url: string | UrlTree, extras?: NavigationBehaviorOptions): Promise<boolean>;
@@ -3004,7 +3118,7 @@ export declare class Router {
3004
3118
  * router.navigate(['team', 33, 'user', 11], {relativeTo: route, skipLocationChange: true});
3005
3119
  * ```
3006
3120
  *
3007
- * @see [Routing and Navigation guide](guide/router)
3121
+ * @see [Routing and Navigation guide](guide/routing/common-router-tasks)
3008
3122
  *
3009
3123
  */
3010
3124
  navigate(commands: any[], extras?: NavigationExtras): Promise<boolean>;
@@ -3190,7 +3304,7 @@ export declare abstract class RouteReuseStrategy {
3190
3304
  * ```
3191
3305
  *
3192
3306
  * @see {@link Event}
3193
- * @see [Router events summary](guide/router-reference#router-events)
3307
+ * @see [Router events summary](guide/routing/router-reference#router-events)
3194
3308
  * @publicApi
3195
3309
  */
3196
3310
  export declare class RouterEvent {
@@ -3619,7 +3733,7 @@ export declare class RouterLinkActive implements OnChanges, OnDestroy, AfterCont
3619
3733
  * * The `forChild()` method creates an `NgModule` that contains all the directives and the given
3620
3734
  * routes, but does not include the `Router` service.
3621
3735
  *
3622
- * @see [Routing and Navigation guide](guide/router) for an
3736
+ * @see [Routing and Navigation guide](guide/routing/common-router-tasks) for an
3623
3737
  * overview of how the `Router` service should be used.
3624
3738
  *
3625
3739
  * @publicApi
@@ -3710,8 +3824,6 @@ export declare class RouterModule {
3710
3824
  * (detach)='onDetach($event)'></router-outlet>
3711
3825
  * ```
3712
3826
  *
3713
- * @see [Routing tutorial](guide/router-tutorial-toh#named-outlets "Example of a named
3714
- * outlet and secondary route configuration").
3715
3827
  * @see {@link RouterLink}
3716
3828
  * @see {@link Route}
3717
3829
  * @ngModule RouterModule
@@ -3724,7 +3836,6 @@ export declare class RouterOutlet implements OnDestroy, OnInit, RouterOutletCont
3724
3836
  /**
3725
3837
  * The name of the outlet
3726
3838
  *
3727
- * @see [named outlets](guide/router-tutorial-toh#displaying-multiple-routes-in-named-outlets)
3728
3839
  */
3729
3840
  name: string;
3730
3841
  activateEvents: EventEmitter<any>;
@@ -3912,7 +4023,7 @@ export declare class RouterPreloader implements OnDestroy {
3912
4023
  * ```
3913
4024
  *
3914
4025
  * @see {@link ActivatedRoute}
3915
- * @see [Getting route information](guide/router#getting-route-information)
4026
+ * @see [Getting route information](guide/routing/common-router-tasks#getting-route-information)
3916
4027
  *
3917
4028
  * @publicApi
3918
4029
  */
@@ -3974,7 +4085,7 @@ export declare const ROUTES: InjectionToken<Route[][]>;
3974
4085
  *
3975
4086
  * @see {@link Route}
3976
4087
  * @see {@link Router}
3977
- * @see [Router configuration guide](guide/router-reference#configuration)
4088
+ * @see [Router configuration guide](guide/routing/router-reference#configuration)
3978
4089
  * @publicApi
3979
4090
  */
3980
4091
  export declare type Routes = Route[];
@@ -4067,7 +4178,7 @@ export declare class Scroll {
4067
4178
  * incorporate titles in named outlets.
4068
4179
  *
4069
4180
  * @publicApi
4070
- * @see [Page title guide](guide/router#setting-the-page-title)
4181
+ * @see [Page title guide](guide/routing/common-router-tasks#setting-the-page-title)
4071
4182
  */
4072
4183
  export declare abstract class TitleStrategy {
4073
4184
  /** Performs the application title update. */
@@ -4107,7 +4218,7 @@ declare class TreeNode<T> {
4107
4218
  *
4108
4219
  * @see {@link Router#navigate}
4109
4220
  * @see {@link Router#createUrlTree}
4110
- * @see [Routing and Navigation guide](guide/router)
4221
+ * @see [Routing and Navigation guide](guide/routing/common-router-tasks)
4111
4222
  *
4112
4223
  * @publicApi
4113
4224
  */
@@ -4655,7 +4766,7 @@ export declare function withInMemoryScrolling(options?: InMemoryScrollingOptions
4655
4766
  /**
4656
4767
  * Provides a function which is called when a navigation error occurs.
4657
4768
  *
4658
- * This function is run inside application's [injection context](guide/dependency-injection-context)
4769
+ * This function is run inside application's [injection context](guide/di/dependency-injection-context)
4659
4770
  * so you can use the [`inject`](api/core/inject) function.
4660
4771
  *
4661
4772
  * @usageNotes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/router",
3
- "version": "18.0.0-next.3",
3
+ "version": "18.0.0-next.5",
4
4
  "description": "Angular - the routing library",
5
5
  "keywords": [
6
6
  "angular",
@@ -24,9 +24,9 @@
24
24
  "tslib": "^2.3.0"
25
25
  },
26
26
  "peerDependencies": {
27
- "@angular/core": "18.0.0-next.3",
28
- "@angular/common": "18.0.0-next.3",
29
- "@angular/platform-browser": "18.0.0-next.3",
27
+ "@angular/core": "18.0.0-next.5",
28
+ "@angular/common": "18.0.0-next.5",
29
+ "@angular/platform-browser": "18.0.0-next.5",
30
30
  "rxjs": "^6.5.3 || ^7.4.0"
31
31
  },
32
32
  "ng-update": {
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @license Angular v18.0.0-next.3
3
- * (c) 2010-2022 Google LLC. https://angular.io/
2
+ * @license Angular v18.0.0-next.5
3
+ * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @license Angular v18.0.0-next.3
3
- * (c) 2010-2022 Google LLC. https://angular.io/
2
+ * @license Angular v18.0.0-next.5
3
+ * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6