1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Angular 14 Access Route Config Title Property in Component

Discussão em 'Angular' iniciado por mtpultz, Outubro 2, 2024.

  1. mtpultz

    mtpultz Guest

    Is it possible to read the title out of the route.snapshot.data of the routeConfig in Angular 14? I can see it in the route.snapshot.data as a Symbol, but can't seem to access it:

    {
    path: 'example',
    title: 'Title of Page',
    component: ExamplePage
    }


    this.route.snapshot.data[Symbol('RouteTitle')]) // undefined
    console.log(this.route.snapshot.data) // { Symbol('RouteTitle'): 'Title of Page' }


    I'm using the TitleStrategy to update the title to be:

    ${title} | ${companyName}`


    But want to get the pre-strategy title in the component for use in the page so they match without using the Title service to getTitle and slicing the companyName off each time.

    Continue reading...

Compartilhe esta Página