Reputation: 19
I'm using ngx-charts line chart component which has a timeline inside. So the structure go like this : MyComponent -> LineChartComponent -> TimelineComponent.
(where LineChartComponent is the component from the library)
Having a reference to LineChartComponent is it possible to execute something like @ViewChild() on this reference to access the TimelineComponent ?
Upvotes: 0
Views: 414
Reputation: 657318
If it's projected, you can use @ContentChild()
, otherwise you need LineChartComponent
to make it available.
The better approach would be to use a shared service that you provide at MyComponent
and inject to MyComponent
and TimelineComponent
and use like a message bus to communicate between these two components for example using Observables.
See also https://angular.io/guide/component-interaction#parent-and-children-communicate-via-a-service
Upvotes: 1