Is there a way to access and call specific methods of child components within a parent component? For example, if we have a ParentCmp
containing two child components (with their selectors and template refs), how can we call certain methods of LoadingPanels
within those child components?
ParentCmp.html
:
....
<child1 #child1></child1>
<child2 #child2></child2>
ParentCmp.ts
:
@ViewChild('child1', read: ComponentRef<child1Cmp>) child1Cmp: ComponentRef<InvitationsBarComponent>;
@ViewChild('child2') meetingsBarCmp: Child2Cmp;
...
child1Cmp.instance.loadingPnl.load(() => {....});
child2Cmp.loadingPnl.load(() => {....});
How can this be achieved?