Skip to content

Ngx meta.withngxmetatitleformatter

Home > @davidlj95/ngx-meta > withNgxMetaTitleFormatter

withNgxMetaTitleFormatter() function

This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Provides a page title formatter.

The formatter will be called with the specified page title metadata. Its output will be the value placed as the page's title by the metadata manager. This way you can prepend or append your site name or brand to all page titles, for instance.

Built-in metadata managers that use this formatter are:

Signature:

withNgxMetaTitleFormatter: (titleFormatter: TitleFormatter) => CoreFeature<CoreFeatureKind.TitleFormatter>

Parameters

Parameter Type Description
titleFormatter TitleFormatter A function that takes the page title set in metadata values and returns the formatted title

Returns:

CoreFeature<CoreFeatureKind.TitleFormatter>

Example

Using standalone, recommended API

provideNgxMetaCore(
  withNgxMetaTitleFormatter((title) => `${title} - Site name`)
)
Using module-based API

NgxMetaCoreModule.forRoot(
  withNgxMetaTitleFormatter((title) => `${title} - Site name`)
)
See also: