I'm trying to pass data from parent component to a child component. I have somthing like that:
Parent component:
@Component({
selector: 'foo-parent',
templateUrl: './foo-parent.component.html',
styleUrls: ['./foo-parent.component.scss'],
})
export class FooParent {
@Input() data: any;
constructor() { }
}
The parent receives the data from another library where all the logic is executed.
Grandchild component:
@Component({
selector: 'foo-grand-child',
templateUrl: './foo-grand-child.component.html',
styleUrls: ['./foo-grand-child.component.sass'],
})
export class FooGrandChild {
data: any;
constructor(private fooParent: FooParent) {
this.data = this.fooParent.fooGrandChildData;
}
This way works correctly but I'm a newbie and I don't know if it's the right way to do it. Is there another way to do it other than bridging the parent > child > grandchild component?