-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Description
Which @angular/* package(s) are relevant/related to the feature request?
router
Description
Since Angular 14, router has a new mechanism to update page title from route config. The route can either be a static string or resolved in the same way as resolve data.
But the resolved route title is not exposed and inaccessible from client application (it seems the title is actually stored in the resolved Data, but using a private Symbol so it can't be accessed properly).
Proposed solution
Expose a new title property on ActivatedRoute and ActivatedRouteSnapshot, just like existing params, data...
Alternatives considered
Alternative 1: Expose the internal RouteTitle symbol used to store title in Data, but this is probably not wanted because it would expose an implementation detail.
Alternative 2: Use TitleStrategy.buildTitle(snapshot: RouterStateSnapshot) or, better, TitleStrategy.getResolvedTitleForRoute(snapshot: ActivatedRouteSnapshot). But this has following drawbacks:
TitleStrategymust be injected where we need to (only) read the route title, which is not its primary purpose...TitleStrategyis not very convenient to inject, because in default case,DefaultTitleStrategyis used but is not available through DI withTitleStrategytoken. To get the actual strategy used, one must retrieve it fromRouter.titleStrategy.- This is inconsistent with existing public api of
ActivatedRoute/ActivatedRouteSnapshot