I have a simple route with 1 parameter:
{
path: 'item/:id',
component: ItemComponent,
data: {title: 'Item detail'}
}
I set the page title using the data header property in the main AppComponent:
export class AppComponent implements OnInit {
title: string;
ngOnInit() {
this.router.events
.. parse it
.subscribe((event) => {
this.title = event['title'];
});
}
}
Then I just show it in the AppComponent template:
<h1>{{ title }}</h1>
The problem is that I want to have a dynamic name, for example "Item detail #name(:id)". Is there any way I can add, for example. route param (: id) or variable in data header property? Sort of
{
path: 'item/:id',
component: ItemComponent,
data: {title: 'Item detail #' + :id }
}
source
share