In my current situation, I am passing a variable's value up to its grand-parent component using EventEmitter successfully. However, once the value reaches the grand-parent, I want to pass it to another child component within that grand-parent. I have tried using @input name:string
in the child component to achieve this, but for some reason, I am unable to access the name variable in that child component.
The parent component setup looks like this:
//html code
<personal-section (childName)="getName($event)"></personal-section>
<profile-section [name]="name"></name>
//inside profile.ts
getName($event) {
console.log(this.name);
this.name= $event;
}
And the child component looks like this:
@Input() name: any;
ngOnChanges() {
if (this.name) {
console.log('users name is ', this.name);
}
}
Although when I trigger a click event in the grand-child component, the value successfully makes its way up to the grand-parent. However, I am encountering issues in accessing it in the final destination - the other child component.
I appreciate any help provided in advance.