Vue router dynamic meta

I have the following

path: '/subject/:subjectname',
  components: {
    default: Student,
    nav: PrimaryNav
  },
  meta: {
    breadcrumb: 'Home Student',
    pagetitle: 'View Subject'
  }

Rather than ‘view subject’ as the page title I would like to use the subject name. Is this possible?

Well, how do you actually set the page title?

@{{this.$route.meta.pagetitle}}

the @ because it is a blade template.

pagetitle: route => `View ${route.params.subjectname}`
<h1>
  @{{this.$route.meta.pagetitle(this.$route) }}
</h1>
2 Likes

Nice one thanks.

meta: {
        breadcrumb: [{
            name: 'Companies',
          },
          {
            name: route => `View ${route.params.company}`,
          }
        ]
      },

But, I am just getting the raw function output.

aa

Can someone help me with this?

2 Likes

This isn’t the correct answer. As @ikram-shah mentions below, this just stringifies the function call.

meta: {
    title: route => route.params.assetid,
},

function title(route) { return route.params.assetid; }

1 Like

As @dwilhel1 said, the function gets printed, not the returned value.
Did anyone find the way?

Did you also make the template change that was suggested?

Yes I did but it didn’t work. What I am doing now is watching the route from the component and manipulating the meta data from there, without touching directly the route file.