Skip to content

Ngx meta.ngxmetaroutedata

Home > @davidlj95/ngx-meta > NgxMetaRouteData

NgxMetaRouteData interface

Utility type to ensure metadata values are set properly inside an Angular `Route.data`

You can also provide specific metadata module types to ensure type safety of the metadata values. Open doc details to see an example.

Signature:

export interface NgxMetaRouteData<Metadata = MetadataValues> 

Remarks

If you don't specify a metadata values type, no type safety will be enforced

const routeData: NgxMetaRouteData = {
  meta: { invalid: 'values' }
}
See example to enforce type safety on metadata values too.

Example

With Typescript's satisfies operator and specifying GlobalMetadata and StandardMetadata types

const routes: Routes = [
  {
    // regular route stuff
    data: {
      meta: { title: 'Foo', standard: { keywords: ['foo', 'bar'] } }
    } satisfies NgxMetaRouteData<GlobalMetadata & StandardMetadata>
  }
]
See metadata values JSON guide for more information about typing the metadata values JSON object.

Properties

Property Modifiers Type Description
meta Metadata