@angular/router 18.0.0-next.4 → 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,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.0.0-next.4
2
+ * @license Angular v18.0.0-next.5
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -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.4", ngImport: i0, type: RouterTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
63
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.0-next.4", ngImport: i0, type: RouterTestingModule, exports: [RouterModule] }); }
64
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.0-next.4", 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.4", 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.4", ngImport: i0, type: RootFixtureService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
101
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.0-next.4", 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.4", 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.4", ngImport: i0, type: RootCmp, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
109
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.0-next.4", 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.4", 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,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.0.0-next.4
2
+ * @license Angular v18.0.0-next.5
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.0.0-next.4
2
+ * @license Angular v18.0.0-next.5
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -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}
@@ -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
  *
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
+ * ```
2093
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.
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/router",
3
- "version": "18.0.0-next.4",
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.4",
28
- "@angular/common": "18.0.0-next.4",
29
- "@angular/platform-browser": "18.0.0-next.4",
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,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.0.0-next.4
2
+ * @license Angular v18.0.0-next.5
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.0.0-next.4
2
+ * @license Angular v18.0.0-next.5
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */