2021-12-02

In Angular 10 is it possible to have different data for dynamic routes

Consider the below dynamic route:

export const routes: Routes = [ 
{  
    path: 'template/:templateId',
    component: TemplateComponent,
    data: { pageTitle: 'TEMPLATES'}
}]

Is it possible to have dynamic pageTitle for same route and same component ?

  • Example:
  • If URL is 'template/01' then I need to set pageTitle in data as 'TEMPLATES-01'.
  • If URL is 'template/02' then I need to set pageTitle in data as 'TEMPLATES-02'.

In this scenario the path remains the same 'template/:templateId' component also remains same 'TemplateComponent' but the URL changes to 'template/01' and 'template/02'.



from Recent Questions - Stack Overflow https://ift.tt/3odVeBv
https://ift.tt/eA8V8J

No comments:

Post a Comment