I need set the header title from child route view...
I have the parent component:
@Component({
selector: 'parent-component',
template: `
<header>{{headerTitle}}</header>
<router-outlet></router-outlet>
`,
directives: [ROUTER_DIRECTIVES]
})
@RouteConfig([
{ path: '/link1', name: 'Link1', component: Link1Component, useAsDefault: true },
{ path: '/link2', name: 'Link2', component: Link2Component },
])
export class ParentComponent {
public sharedHeaderTitle: string;
constructor(public router: Router) { }
}
Have a childs routing tabs:
@Component({
template: '<div></div>'
})
export class Link1Component {
public headerTitle: string;
constructor() {
this.headerTitle = "Link1 page";
}
}
and another one
@Component({
template: '<div></div>'
})
export class Link2Component {
public headerTitle: string;
constructor() {
this.headerTitle = "Link2 page";
}
}
How it make in parent-childs I found here but its not working with routing...
What is best way to make it?
SOLVED
I found one solution, think it's the best way:
http://plnkr.co/edit/LYTXmY9Fwm8LwumICWDT