[ Web Proxy ]
URL:
Viewing: https://angular.dev/api/router/TitleStrategy [Back]  [Original]

TitleStrategy Angular Skip to main content
menu
close
more_horiz
menuAPI
@angular/router

TitleStrategy

Class
stable

Provides a strategy for setting the page title after a router navigation.

Page title guide

On this page

    arrow_upward_alt Back to the top

    API

        
          abstract class TitleStrategy {  abstract updateTitle(snapshot: RouterStateSnapshot): void;  buildTitle(snapshot: RouterStateSnapshot): string | undefined;  getResolvedTitleForRoute(snapshot: ActivatedRouteSnapshot): string | undefined;}
        
        

    updateTitle

    void

    Performs the application title update.

    @paramsnapshotRouterStateSnapshot
    @returnsvoid

    buildTitle

    string | undefined
    @paramsnapshotRouterStateSnapshot
    @returnsstring | undefined

    The title of the deepest primary route.

    getResolvedTitleForRoute

    string | undefined

    Given an ActivatedRouteSnapshot, returns the final value of the Route.title property, which can either be a static string or a resolved value.

    @returnsstring | undefined

    Description

    Provides a strategy for setting the page title after a router navigation.

    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.

    Jump to details

    Web Proxy Viewer  |  New URL  |  Original Page