On this page
TitleStrategy
class
Provides a strategy for setting the page title after a router navigation.
abstract class TitleStrategy {
abstract updateTitle(snapshot: RouterStateSnapshot): void
buildTitle(snapshot: RouterStateSnapshot): string | undefined
getResolvedTitleForRoute(snapshot: ActivatedRouteSnapshot)
}
Subclasses
See also
Provided in
'root'
Description
The built-in implementation traverses the router state snapshot and finds the deepest primary outlet with title
property. Given the Routes
below, navigating to /base/child(popup:aux)
would result in the document title being set to "child".
[
{path: 'base', title: 'base', children: [
{path: 'child', title: 'child'},
],
{path: 'aux', outlet: 'popup', title: 'popupTitle'}
]
This class can be used as a base class for custom title strategies. That is, you can create your own class that extends the TitleStrategy
. Note that in the above example, the title
from the named outlet is never used. However, a custom strategy might be implemented to incorporate titles in named outlets.
Methods
updateTitle()
|
|||
---|---|---|---|
Performs the application title update. |
|||
|
snapshot |
RouterStateSnapshot |
Returns
void
buildTitle()
|
|||
---|---|---|---|
|
snapshot |
RouterStateSnapshot |
Returns
string | undefined
: The title
of the deepest primary route.
getResolvedTitleForRoute()
|
|||
---|---|---|---|
Given an |
|||
|
snapshot |
ActivatedRouteSnapshot |
© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v14.angular.io/api/router/TitleStrategy