Basically scenario is, i am shifting the value of variable up to its grand-parent component using EventEmitter (till now its working fine).
but once value reaches at grand-parent i want to pass that value to its another child component. i am doing it with @input name:string at child component. but don't know why i am not able to get that name in that child component.
parent =>
//html code
<personal-section (childName)="getName($event)"></personal-section>
<profile-section [name]="name"></name>
//inside profile.ts
getName($event) {
console.log(this.name); // <--- upto this console, program works fine
this.name= $event;
}
child =>
@Input() name: any;
ngOnChanges() {
if (this.name) {
console.log('users name is ', this.name); //<--this never prints.
}
}
but whenever i perform click event in grand-child's component, value perfectly reaches upto its grand-parent. but after that i am not able to get it in its another child i.e final destination ;)
Thanks in advance.
getName($event)withgetName(event), the $ is unnecessary in the controller. 2. Please do a console.log ofeventinsidegetName(event)and post the result to the question. - Michael D