update of @Vladimir Tolstikov's answer
Create a Child Component that use ngOnChanges
.
ChildComponent.ts::
import { Component, OnChanges, Input } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'child',
templateUrl: 'child.component.html',
})
export class ChildComponent implements OnChanges {
@Input() child_id;
constructor(private route: ActivatedRoute) { }
ngOnChanges() {
// create header using child_id
console.log(this.child_id);
}
}
now use it in MasterComponent's template and pass data to ChildComponent like:
<child [child_id]="child_id"></child>