Hello i would like to share title between components. I have component app.component which declare title property and all another components are children. I have page-header.component which write title to html and dashboard.component which set title property and title dont show. Here is my code:
app.component
export class AppComponent implements OnInit {
title: string;
ngOnInit(): void {
}
}
page-header.component
export class PageHeaderComponent extends AppComponent implements OnInit {
constructor() {
super();
}
ngOnInit() {
super.ngOnInit();
}
}
page-header.component.html
<h1>{{title}}</h1>
dashboard.component
export class DashboardComponent extends AppComponent {
constructor() {
super();
}
ngOnInit() {
super.ngOnInit();
this.title = "Dashboard";
}
}
For greater clarity i added image:

I would like to easy set title in any component (child of AppComponent) and title will be write to page header component
common-componentand use it across the page by having the other components as child