@angular/router 13.2.0 → 14.0.0-next.2
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/esm2020/src/apply_redirects.mjs +2 -2
- package/esm2020/src/components/empty_outlet.mjs +3 -3
- package/esm2020/src/directives/router_link.mjs +14 -17
- package/esm2020/src/directives/router_link_active.mjs +3 -3
- package/esm2020/src/directives/router_outlet.mjs +4 -4
- package/esm2020/src/events.mjs +1 -1
- package/esm2020/src/index.mjs +2 -1
- package/esm2020/src/models.mjs +14 -0
- package/esm2020/src/operators/activate_routes.mjs +1 -1
- package/esm2020/src/operators/apply_redirects.mjs +1 -1
- package/esm2020/src/operators/check_guards.mjs +1 -1
- package/esm2020/src/operators/recognize.mjs +1 -1
- package/esm2020/src/operators/resolve_data.mjs +18 -2
- package/esm2020/src/page_title_strategy.mjs +84 -0
- package/esm2020/src/private_export.mjs +1 -1
- package/esm2020/src/recognize.mjs +1 -1
- package/esm2020/src/router.mjs +7 -6
- package/esm2020/src/router_config_loader.mjs +2 -2
- package/esm2020/src/router_module.mjs +13 -11
- package/esm2020/src/router_preloader.mjs +4 -4
- package/esm2020/src/router_scroller.mjs +3 -3
- package/esm2020/src/router_state.mjs +1 -1
- package/esm2020/src/shared.mjs +1 -1
- package/esm2020/src/utils/config.mjs +1 -1
- package/esm2020/src/utils/config_matching.mjs +1 -1
- package/esm2020/src/utils/preactivation.mjs +1 -1
- package/esm2020/src/utils/type_guards.mjs +1 -1
- package/esm2020/src/version.mjs +1 -1
- package/esm2020/testing/src/router_testing_module.mjs +39 -15
- package/esm2020/upgrade/src/upgrade.mjs +15 -5
- package/fesm2015/router.mjs +146 -50
- package/fesm2015/router.mjs.map +1 -1
- package/fesm2015/testing.mjs +40 -16
- package/fesm2015/testing.mjs.map +1 -1
- package/fesm2015/upgrade.mjs +16 -5
- package/fesm2015/upgrade.mjs.map +1 -1
- package/fesm2020/router.mjs +144 -50
- package/fesm2020/router.mjs.map +1 -1
- package/fesm2020/testing.mjs +40 -16
- package/fesm2020/testing.mjs.map +1 -1
- package/fesm2020/upgrade.mjs +15 -5
- package/fesm2020/upgrade.mjs.map +1 -1
- package/package.json +4 -4
- package/router.d.ts +77 -6
- package/testing/testing.d.ts +10 -2
- package/upgrade/upgrade.d.ts +1 -1
- package/esm2020/src/config.mjs +0 -14
- package/esm2020/src/interfaces.mjs +0 -9
package/fesm2020/router.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular
|
|
2
|
+
* @license Angular v14.0.0-next.2
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
import * as i3 from '@angular/common';
|
|
8
8
|
import { Location, LocationStrategy, PlatformLocation, APP_BASE_HREF, ViewportScroller, HashLocationStrategy, PathLocationStrategy, LOCATION_INITIALIZED } from '@angular/common';
|
|
9
9
|
import * as i0 from '@angular/core';
|
|
10
|
-
import { ɵisObservable, ɵisPromise, EventEmitter, Directive, Attribute, Output, Component, NgModuleRef, InjectionToken, InjectFlags, NgModuleFactory, ɵConsole, NgZone, Injectable, Input, HostListener, HostBinding, Optional, ContentChildren, Injector, Compiler, NgProbeToken, ANALYZE_FOR_ENTRY_COMPONENTS, SkipSelf, Inject, APP_INITIALIZER, APP_BOOTSTRAP_LISTENER, NgModule, ApplicationRef, Version } from '@angular/core';
|
|
10
|
+
import { ɵisObservable, ɵisPromise, EventEmitter, Directive, Attribute, Output, Component, NgModuleRef, InjectionToken, InjectFlags, NgModuleFactory, ɵConsole, NgZone, Injectable, ɵcoerceToBoolean, Input, HostListener, HostBinding, Optional, ContentChildren, Injector, Compiler, NgProbeToken, ANALYZE_FOR_ENTRY_COMPONENTS, SkipSelf, Inject, APP_INITIALIZER, APP_BOOTSTRAP_LISTENER, NgModule, ApplicationRef, Version } from '@angular/core';
|
|
11
11
|
import { from, of, BehaviorSubject, combineLatest, Observable, EmptyError, concat, defer, EMPTY, ConnectableObservable, Subject } from 'rxjs';
|
|
12
12
|
import { map, switchMap, take, startWith, scan, filter, catchError, concatMap, last as last$1, first, mergeMap, tap, takeLast, refCount, finalize, mergeAll } from 'rxjs/operators';
|
|
13
|
+
import * as i1 from '@angular/platform-browser';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* @license
|
|
@@ -2524,9 +2525,9 @@ class RouterOutlet {
|
|
|
2524
2525
|
this.activateEvents.emit(this.activated.instance);
|
|
2525
2526
|
}
|
|
2526
2527
|
}
|
|
2527
|
-
RouterOutlet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2528
|
-
RouterOutlet.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "
|
|
2529
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2528
|
+
RouterOutlet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterOutlet, deps: [{ token: ChildrenOutletContexts }, { token: i0.ViewContainerRef }, { token: i0.ComponentFactoryResolver }, { token: 'name', attribute: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2529
|
+
RouterOutlet.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.2", type: RouterOutlet, selector: "router-outlet", outputs: { activateEvents: "activate", deactivateEvents: "deactivate", attachEvents: "attach", detachEvents: "detach" }, exportAs: ["outlet"], ngImport: i0 });
|
|
2530
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterOutlet, decorators: [{
|
|
2530
2531
|
type: Directive,
|
|
2531
2532
|
args: [{ selector: 'router-outlet', exportAs: 'outlet' }]
|
|
2532
2533
|
}], ctorParameters: function () { return [{ type: ChildrenOutletContexts }, { type: i0.ViewContainerRef }, { type: i0.ComponentFactoryResolver }, { type: undefined, decorators: [{
|
|
@@ -2580,9 +2581,9 @@ class OutletInjector {
|
|
|
2580
2581
|
*/
|
|
2581
2582
|
class ɵEmptyOutletComponent {
|
|
2582
2583
|
}
|
|
2583
|
-
ɵEmptyOutletComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2584
|
-
ɵEmptyOutletComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "
|
|
2585
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2584
|
+
ɵEmptyOutletComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: ɵEmptyOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2585
|
+
ɵEmptyOutletComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "14.0.0-next.2", type: ɵEmptyOutletComponent, selector: "ng-component", ngImport: i0, template: `<router-outlet></router-outlet>`, isInline: true, directives: [{ type: RouterOutlet, selector: "router-outlet", outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] });
|
|
2586
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: ɵEmptyOutletComponent, decorators: [{
|
|
2586
2587
|
type: Component,
|
|
2587
2588
|
args: [{ template: `<router-outlet></router-outlet>` }]
|
|
2588
2589
|
}] });
|
|
@@ -3786,6 +3787,12 @@ function recognize(rootComponentType, config, serializer, paramsInheritanceStrat
|
|
|
3786
3787
|
* Use of this source code is governed by an MIT-style license that can be
|
|
3787
3788
|
* found in the LICENSE file at https://angular.io/license
|
|
3788
3789
|
*/
|
|
3790
|
+
/**
|
|
3791
|
+
* A private symbol used to store the value of `Route.title` inside the `Route.data` if it is a
|
|
3792
|
+
* static string or `Route.resolve` if anything else. This allows us to reuse the existing route
|
|
3793
|
+
* data/resolvers to support the title feature without new instrumentation in the `Router` pipeline.
|
|
3794
|
+
*/
|
|
3795
|
+
const RouteTitle = Symbol('RouteTitle');
|
|
3789
3796
|
function resolveData(paramsInheritanceStrategy, moduleInjector) {
|
|
3790
3797
|
return mergeMap(t => {
|
|
3791
3798
|
const { targetSnapshot, guards: { canActivateChecks } } = t;
|
|
@@ -3798,12 +3805,22 @@ function resolveData(paramsInheritanceStrategy, moduleInjector) {
|
|
|
3798
3805
|
});
|
|
3799
3806
|
}
|
|
3800
3807
|
function runResolve(futureARS, futureRSS, paramsInheritanceStrategy, moduleInjector) {
|
|
3808
|
+
const config = futureARS.routeConfig;
|
|
3801
3809
|
const resolve = futureARS._resolve;
|
|
3810
|
+
const data = { ...futureARS.data };
|
|
3811
|
+
if (config?.title !== undefined) {
|
|
3812
|
+
if (typeof config.title === 'string' || config.title === null) {
|
|
3813
|
+
data[RouteTitle] = config.title;
|
|
3814
|
+
}
|
|
3815
|
+
else {
|
|
3816
|
+
resolve[RouteTitle] = config.title;
|
|
3817
|
+
}
|
|
3818
|
+
}
|
|
3802
3819
|
return resolveNode(resolve, futureARS, futureRSS, moduleInjector)
|
|
3803
3820
|
.pipe(map((resolvedData) => {
|
|
3804
3821
|
futureARS._resolvedData = resolvedData;
|
|
3805
3822
|
futureARS.data = {
|
|
3806
|
-
...
|
|
3823
|
+
...data,
|
|
3807
3824
|
...inheritedParamsDataResolve(futureARS, paramsInheritanceStrategy).resolve
|
|
3808
3825
|
};
|
|
3809
3826
|
return null;
|
|
@@ -4149,7 +4166,7 @@ class Router {
|
|
|
4149
4166
|
*/
|
|
4150
4167
|
this.onSameUrlNavigation = 'ignore';
|
|
4151
4168
|
/**
|
|
4152
|
-
* How to merge parameters, data,
|
|
4169
|
+
* How to merge parameters, data, resolved data, and title from parent to child
|
|
4153
4170
|
* routes. One of:
|
|
4154
4171
|
*
|
|
4155
4172
|
* - `'emptyOnly'` : Inherit parent parameters, data, and resolved data
|
|
@@ -4252,7 +4269,7 @@ class Router {
|
|
|
4252
4269
|
tap(t => {
|
|
4253
4270
|
this.currentNavigation = {
|
|
4254
4271
|
id: t.id,
|
|
4255
|
-
initialUrl: t.
|
|
4272
|
+
initialUrl: t.rawUrl,
|
|
4256
4273
|
extractedUrl: t.extractedUrl,
|
|
4257
4274
|
trigger: t.source,
|
|
4258
4275
|
extras: t.extras,
|
|
@@ -4821,6 +4838,7 @@ class Router {
|
|
|
4821
4838
|
this.events
|
|
4822
4839
|
.next(new NavigationEnd(t.id, this.serializeUrl(t.extractedUrl), this.serializeUrl(this.currentUrlTree)));
|
|
4823
4840
|
this.lastSuccessfulNavigation = this.currentNavigation;
|
|
4841
|
+
this.titleStrategy?.updateTitle(this.routerState.snapshot);
|
|
4824
4842
|
t.resolve(true);
|
|
4825
4843
|
}, e => {
|
|
4826
4844
|
this.console.warn(`Unhandled Navigation Error: ${e}`);
|
|
@@ -4985,9 +5003,9 @@ class Router {
|
|
|
4985
5003
|
return { navigationId };
|
|
4986
5004
|
}
|
|
4987
5005
|
}
|
|
4988
|
-
Router.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
4989
|
-
Router.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
4990
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
5006
|
+
Router.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: Router, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
|
|
5007
|
+
Router.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: Router });
|
|
5008
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: Router, decorators: [{
|
|
4991
5009
|
type: Injectable
|
|
4992
5010
|
}], ctorParameters: function () { return [{ type: i0.Type }, { type: UrlSerializer }, { type: ChildrenOutletContexts }, { type: i3.Location }, { type: i0.Injector }, { type: i0.Compiler }, { type: undefined }]; } });
|
|
4993
5011
|
function validateCommands(commands) {
|
|
@@ -5164,8 +5182,8 @@ class RouterLink {
|
|
|
5164
5182
|
return true;
|
|
5165
5183
|
}
|
|
5166
5184
|
const extras = {
|
|
5167
|
-
skipLocationChange:
|
|
5168
|
-
replaceUrl:
|
|
5185
|
+
skipLocationChange: ɵcoerceToBoolean(this.skipLocationChange),
|
|
5186
|
+
replaceUrl: ɵcoerceToBoolean(this.replaceUrl),
|
|
5169
5187
|
state: this.state,
|
|
5170
5188
|
};
|
|
5171
5189
|
this.router.navigateByUrl(this.urlTree, extras);
|
|
@@ -5182,13 +5200,13 @@ class RouterLink {
|
|
|
5182
5200
|
queryParams: this.queryParams,
|
|
5183
5201
|
fragment: this.fragment,
|
|
5184
5202
|
queryParamsHandling: this.queryParamsHandling,
|
|
5185
|
-
preserveFragment:
|
|
5203
|
+
preserveFragment: ɵcoerceToBoolean(this.preserveFragment),
|
|
5186
5204
|
});
|
|
5187
5205
|
}
|
|
5188
5206
|
}
|
|
5189
|
-
RouterLink.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
5190
|
-
RouterLink.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "
|
|
5191
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
5207
|
+
RouterLink.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterLink, deps: [{ token: Router }, { token: ActivatedRoute }, { token: 'tabindex', attribute: true }, { token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
5208
|
+
RouterLink.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.2", type: RouterLink, selector: ":not(a):not(area)[routerLink]", inputs: { queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick()" } }, usesOnChanges: true, ngImport: i0 });
|
|
5209
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterLink, decorators: [{
|
|
5192
5210
|
type: Directive,
|
|
5193
5211
|
args: [{ selector: ':not(a):not(area)[routerLink]' }]
|
|
5194
5212
|
}], ctorParameters: function () { return [{ type: Router }, { type: ActivatedRoute }, { type: undefined, decorators: [{
|
|
@@ -5278,8 +5296,8 @@ class RouterLinkWithHref {
|
|
|
5278
5296
|
return true;
|
|
5279
5297
|
}
|
|
5280
5298
|
const extras = {
|
|
5281
|
-
skipLocationChange:
|
|
5282
|
-
replaceUrl:
|
|
5299
|
+
skipLocationChange: ɵcoerceToBoolean(this.skipLocationChange),
|
|
5300
|
+
replaceUrl: ɵcoerceToBoolean(this.replaceUrl),
|
|
5283
5301
|
state: this.state
|
|
5284
5302
|
};
|
|
5285
5303
|
this.router.navigateByUrl(this.urlTree, extras);
|
|
@@ -5301,13 +5319,13 @@ class RouterLinkWithHref {
|
|
|
5301
5319
|
queryParams: this.queryParams,
|
|
5302
5320
|
fragment: this.fragment,
|
|
5303
5321
|
queryParamsHandling: this.queryParamsHandling,
|
|
5304
|
-
preserveFragment:
|
|
5322
|
+
preserveFragment: ɵcoerceToBoolean(this.preserveFragment),
|
|
5305
5323
|
});
|
|
5306
5324
|
}
|
|
5307
5325
|
}
|
|
5308
|
-
RouterLinkWithHref.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
5309
|
-
RouterLinkWithHref.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "
|
|
5310
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
5326
|
+
RouterLinkWithHref.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterLinkWithHref, deps: [{ token: Router }, { token: ActivatedRoute }, { token: i3.LocationStrategy }], target: i0.ɵɵFactoryTarget.Directive });
|
|
5327
|
+
RouterLinkWithHref.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.2", type: RouterLinkWithHref, selector: "a[routerLink],area[routerLink]", inputs: { target: "target", queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick($event.button,$event.ctrlKey,$event.shiftKey,$event.altKey,$event.metaKey)" }, properties: { "attr.target": "this.target", "attr.href": "this.href" } }, usesOnChanges: true, ngImport: i0 });
|
|
5328
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterLinkWithHref, decorators: [{
|
|
5311
5329
|
type: Directive,
|
|
5312
5330
|
args: [{ selector: 'a[routerLink],area[routerLink]' }]
|
|
5313
5331
|
}], ctorParameters: function () { return [{ type: Router }, { type: ActivatedRoute }, { type: i3.LocationStrategy }]; }, propDecorators: { target: [{
|
|
@@ -5341,9 +5359,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImpor
|
|
|
5341
5359
|
args: ['click',
|
|
5342
5360
|
['$event.button', '$event.ctrlKey', '$event.shiftKey', '$event.altKey', '$event.metaKey']]
|
|
5343
5361
|
}] } });
|
|
5344
|
-
function attrBoolValue(s) {
|
|
5345
|
-
return s === '' || !!s;
|
|
5346
|
-
}
|
|
5347
5362
|
|
|
5348
5363
|
/**
|
|
5349
5364
|
* @license
|
|
@@ -5519,9 +5534,9 @@ class RouterLinkActive {
|
|
|
5519
5534
|
this.links.some(isActiveCheckFn) || this.linksWithHrefs.some(isActiveCheckFn);
|
|
5520
5535
|
}
|
|
5521
5536
|
}
|
|
5522
|
-
RouterLinkActive.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
5523
|
-
RouterLinkActive.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "
|
|
5524
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
5537
|
+
RouterLinkActive.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterLinkActive, deps: [{ token: Router }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: RouterLink, optional: true }, { token: RouterLinkWithHref, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
5538
|
+
RouterLinkActive.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.2", type: RouterLinkActive, selector: "[routerLinkActive]", inputs: { routerLinkActiveOptions: "routerLinkActiveOptions", routerLinkActive: "routerLinkActive" }, outputs: { isActiveChange: "isActiveChange" }, queries: [{ propertyName: "links", predicate: RouterLink, descendants: true }, { propertyName: "linksWithHrefs", predicate: RouterLinkWithHref, descendants: true }], exportAs: ["routerLinkActive"], usesOnChanges: true, ngImport: i0 });
|
|
5539
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterLinkActive, decorators: [{
|
|
5525
5540
|
type: Directive,
|
|
5526
5541
|
args: [{
|
|
5527
5542
|
selector: '[routerLinkActive]',
|
|
@@ -5551,6 +5566,84 @@ function isActiveMatchOptions(options) {
|
|
|
5551
5566
|
return !!options.paths;
|
|
5552
5567
|
}
|
|
5553
5568
|
|
|
5569
|
+
/**
|
|
5570
|
+
* @license
|
|
5571
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5572
|
+
*
|
|
5573
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
5574
|
+
* found in the LICENSE file at https://angular.io/license
|
|
5575
|
+
*/
|
|
5576
|
+
/**
|
|
5577
|
+
* Provides a strategy for setting the page title after a router navigation.
|
|
5578
|
+
*
|
|
5579
|
+
* The built-in implementation traverses the router state snapshot and finds the deepest primary
|
|
5580
|
+
* outlet with `title` property. Given the `Routes` below, navigating to
|
|
5581
|
+
* `/base/child(popup:aux)` would result in the document title being set to "child".
|
|
5582
|
+
* ```
|
|
5583
|
+
* [
|
|
5584
|
+
* {path: 'base', title: 'base', children: [
|
|
5585
|
+
* {path: 'child', title: 'child'},
|
|
5586
|
+
* ],
|
|
5587
|
+
* {path: 'aux', outlet: 'popup', title: 'popupTitle'}
|
|
5588
|
+
* ]
|
|
5589
|
+
* ```
|
|
5590
|
+
*
|
|
5591
|
+
* This class can be used as a base class for custom title strategies. That is, you can create your
|
|
5592
|
+
* own class that extends the `TitleStrategy`. Note that in the above example, the `title`
|
|
5593
|
+
* from the named outlet is never used. However, a custom strategy might be implemented to
|
|
5594
|
+
* incorporate titles in named outlets.
|
|
5595
|
+
*
|
|
5596
|
+
* @publicApi
|
|
5597
|
+
* @see [Page title guide](guide/router#setting-the-page-title)
|
|
5598
|
+
*/
|
|
5599
|
+
class TitleStrategy {
|
|
5600
|
+
/**
|
|
5601
|
+
* @returns The `title` of the deepest primary route.
|
|
5602
|
+
*/
|
|
5603
|
+
buildTitle(snapshot) {
|
|
5604
|
+
let pageTitle;
|
|
5605
|
+
let route = snapshot.root;
|
|
5606
|
+
while (route !== undefined) {
|
|
5607
|
+
pageTitle = this.getResolvedTitleForRoute(route) ?? pageTitle;
|
|
5608
|
+
route = route.children.find(child => child.outlet === PRIMARY_OUTLET);
|
|
5609
|
+
}
|
|
5610
|
+
return pageTitle;
|
|
5611
|
+
}
|
|
5612
|
+
/**
|
|
5613
|
+
* Given an `ActivatedRouteSnapshot`, returns the final value of the
|
|
5614
|
+
* `Route.title` property, which can either be a static string or a resolved value.
|
|
5615
|
+
*/
|
|
5616
|
+
getResolvedTitleForRoute(snapshot) {
|
|
5617
|
+
return snapshot.data[RouteTitle];
|
|
5618
|
+
}
|
|
5619
|
+
}
|
|
5620
|
+
/**
|
|
5621
|
+
* The default `TitleStrategy` used by the router that updates the title using the `Title` service.
|
|
5622
|
+
*/
|
|
5623
|
+
class DefaultTitleStrategy extends TitleStrategy {
|
|
5624
|
+
constructor(title) {
|
|
5625
|
+
super();
|
|
5626
|
+
this.title = title;
|
|
5627
|
+
}
|
|
5628
|
+
/**
|
|
5629
|
+
* Sets the title of the browser to the given value.
|
|
5630
|
+
*
|
|
5631
|
+
* @param title The `pageTitle` from the deepest primary route.
|
|
5632
|
+
*/
|
|
5633
|
+
updateTitle(snapshot) {
|
|
5634
|
+
const title = this.buildTitle(snapshot);
|
|
5635
|
+
if (title !== undefined) {
|
|
5636
|
+
this.title.setTitle(title);
|
|
5637
|
+
}
|
|
5638
|
+
}
|
|
5639
|
+
}
|
|
5640
|
+
DefaultTitleStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: DefaultTitleStrategy, deps: [{ token: i1.Title }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
5641
|
+
DefaultTitleStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: DefaultTitleStrategy, providedIn: 'root' });
|
|
5642
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: DefaultTitleStrategy, decorators: [{
|
|
5643
|
+
type: Injectable,
|
|
5644
|
+
args: [{ providedIn: 'root' }]
|
|
5645
|
+
}], ctorParameters: function () { return [{ type: i1.Title }]; } });
|
|
5646
|
+
|
|
5554
5647
|
/**
|
|
5555
5648
|
* @license
|
|
5556
5649
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -5664,9 +5757,9 @@ class RouterPreloader {
|
|
|
5664
5757
|
});
|
|
5665
5758
|
}
|
|
5666
5759
|
}
|
|
5667
|
-
RouterPreloader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
5668
|
-
RouterPreloader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
5669
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
5760
|
+
RouterPreloader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterPreloader, deps: [{ token: Router }, { token: i0.Compiler }, { token: i0.Injector }, { token: PreloadingStrategy }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
5761
|
+
RouterPreloader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterPreloader });
|
|
5762
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterPreloader, decorators: [{
|
|
5670
5763
|
type: Injectable
|
|
5671
5764
|
}], ctorParameters: function () { return [{ type: Router }, { type: i0.Compiler }, { type: i0.Injector }, { type: PreloadingStrategy }]; } });
|
|
5672
5765
|
|
|
@@ -5752,9 +5845,9 @@ class RouterScroller {
|
|
|
5752
5845
|
}
|
|
5753
5846
|
}
|
|
5754
5847
|
}
|
|
5755
|
-
RouterScroller.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
5756
|
-
RouterScroller.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
5757
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
5848
|
+
RouterScroller.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterScroller, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
|
|
5849
|
+
RouterScroller.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterScroller });
|
|
5850
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterScroller, decorators: [{
|
|
5758
5851
|
type: Injectable
|
|
5759
5852
|
}], ctorParameters: function () { return [{ type: Router }, { type: i3.ViewportScroller }, { type: undefined }]; } });
|
|
5760
5853
|
|
|
@@ -5787,8 +5880,8 @@ const ROUTER_PROVIDERS = [
|
|
|
5787
5880
|
useFactory: setupRouter,
|
|
5788
5881
|
deps: [
|
|
5789
5882
|
UrlSerializer, ChildrenOutletContexts, Location, Injector, Compiler, ROUTES,
|
|
5790
|
-
ROUTER_CONFIGURATION, [
|
|
5791
|
-
[RouteReuseStrategy, new Optional()]
|
|
5883
|
+
ROUTER_CONFIGURATION, DefaultTitleStrategy, [TitleStrategy, new Optional()],
|
|
5884
|
+
[UrlHandlingStrategy, new Optional()], [RouteReuseStrategy, new Optional()]
|
|
5792
5885
|
]
|
|
5793
5886
|
},
|
|
5794
5887
|
ChildrenOutletContexts,
|
|
@@ -5895,10 +5988,10 @@ class RouterModule {
|
|
|
5895
5988
|
return { ngModule: RouterModule, providers: [provideRoutes(routes)] };
|
|
5896
5989
|
}
|
|
5897
5990
|
}
|
|
5898
|
-
RouterModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
5899
|
-
RouterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "
|
|
5900
|
-
RouterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
5901
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
5991
|
+
RouterModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterModule, deps: [{ token: ROUTER_FORROOT_GUARD, optional: true }, { token: Router, optional: true }], target: i0.ɵɵFactoryTarget.NgModule });
|
|
5992
|
+
RouterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterModule, declarations: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent], exports: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent] });
|
|
5993
|
+
RouterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterModule });
|
|
5994
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterModule, decorators: [{
|
|
5902
5995
|
type: NgModule,
|
|
5903
5996
|
args: [{
|
|
5904
5997
|
declarations: ROUTER_DIRECTIVES,
|
|
@@ -5950,7 +6043,7 @@ function provideRoutes(routes) {
|
|
|
5950
6043
|
{ provide: ROUTES, multi: true, useValue: routes },
|
|
5951
6044
|
];
|
|
5952
6045
|
}
|
|
5953
|
-
function setupRouter(urlSerializer, contexts, location, injector, compiler, config, opts = {}, urlHandlingStrategy, routeReuseStrategy) {
|
|
6046
|
+
function setupRouter(urlSerializer, contexts, location, injector, compiler, config, opts = {}, defaultTitleStrategy, titleStrategy, urlHandlingStrategy, routeReuseStrategy) {
|
|
5954
6047
|
const router = new Router(null, urlSerializer, contexts, location, injector, compiler, flatten(config));
|
|
5955
6048
|
if (urlHandlingStrategy) {
|
|
5956
6049
|
router.urlHandlingStrategy = urlHandlingStrategy;
|
|
@@ -5958,6 +6051,7 @@ function setupRouter(urlSerializer, contexts, location, injector, compiler, conf
|
|
|
5958
6051
|
if (routeReuseStrategy) {
|
|
5959
6052
|
router.routeReuseStrategy = routeReuseStrategy;
|
|
5960
6053
|
}
|
|
6054
|
+
router.titleStrategy = titleStrategy ?? defaultTitleStrategy;
|
|
5961
6055
|
assignExtraOptionsToRouter(opts, router);
|
|
5962
6056
|
if (opts.enableTracing) {
|
|
5963
6057
|
router.events.subscribe((e) => {
|
|
@@ -6076,9 +6170,9 @@ class RouterInitializer {
|
|
|
6076
6170
|
this.destroyed = true;
|
|
6077
6171
|
}
|
|
6078
6172
|
}
|
|
6079
|
-
RouterInitializer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
6080
|
-
RouterInitializer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
6081
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
6173
|
+
RouterInitializer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterInitializer, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
6174
|
+
RouterInitializer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterInitializer });
|
|
6175
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.2", ngImport: i0, type: RouterInitializer, decorators: [{
|
|
6082
6176
|
type: Injectable
|
|
6083
6177
|
}], ctorParameters: function () { return [{ type: i0.Injector }]; } });
|
|
6084
6178
|
function getAppInitializer(r) {
|
|
@@ -6118,7 +6212,7 @@ function provideRouterInitializer() {
|
|
|
6118
6212
|
/**
|
|
6119
6213
|
* @publicApi
|
|
6120
6214
|
*/
|
|
6121
|
-
const VERSION = new Version('
|
|
6215
|
+
const VERSION = new Version('14.0.0-next.2');
|
|
6122
6216
|
|
|
6123
6217
|
/**
|
|
6124
6218
|
* @license
|
|
@@ -6157,5 +6251,5 @@ const VERSION = new Version('13.2.0');
|
|
|
6157
6251
|
* Generated bundle index. Do not edit.
|
|
6158
6252
|
*/
|
|
6159
6253
|
|
|
6160
|
-
export { ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, BaseRouteReuseStrategy, ChildActivationEnd, ChildActivationStart, ChildrenOutletContexts, DefaultUrlSerializer, GuardsCheckEnd, GuardsCheckStart, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, NoPreloading, OutletContext, PRIMARY_OUTLET, PreloadAllModules, PreloadingStrategy, ROUTER_CONFIGURATION, ROUTER_INITIALIZER, ROUTES, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, Router, RouterEvent, RouterLink, RouterLinkActive, RouterLinkWithHref, RouterModule, RouterOutlet, RouterPreloader, RouterState, RouterStateSnapshot, RoutesRecognized, Scroll, UrlHandlingStrategy, UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree, VERSION, convertToParamMap, provideRoutes, ɵEmptyOutletComponent, ROUTER_PROVIDERS as ɵROUTER_PROVIDERS, assignExtraOptionsToRouter as ɵassignExtraOptionsToRouter, flatten as ɵflatten };
|
|
6254
|
+
export { ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, BaseRouteReuseStrategy, ChildActivationEnd, ChildActivationStart, ChildrenOutletContexts, DefaultTitleStrategy, DefaultUrlSerializer, GuardsCheckEnd, GuardsCheckStart, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, NoPreloading, OutletContext, PRIMARY_OUTLET, PreloadAllModules, PreloadingStrategy, ROUTER_CONFIGURATION, ROUTER_INITIALIZER, ROUTES, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, Router, RouterEvent, RouterLink, RouterLinkActive, RouterLinkWithHref, RouterModule, RouterOutlet, RouterPreloader, RouterState, RouterStateSnapshot, RoutesRecognized, Scroll, TitleStrategy, UrlHandlingStrategy, UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree, VERSION, convertToParamMap, provideRoutes, ɵEmptyOutletComponent, ROUTER_PROVIDERS as ɵROUTER_PROVIDERS, assignExtraOptionsToRouter as ɵassignExtraOptionsToRouter, flatten as ɵflatten };
|
|
6161
6255
|
//# sourceMappingURL=router.mjs.map
|