Within my application, there exists a parent component (pc) along with 4 child components (cc1, cc2, cc3, and cc4). Imagine a situation where a user inputs a number between 1-4 into a text field, and I want to call a specific function in the corresponding child component.
For instance, if I wanted to execute a function from child component 2, I could use @ViewChild:
@ViewChild('cc2') child;
and then invoke the function using:
this.child.somefunc();
However, it is not possible to achieve something like this:
@ViewChild('cc' + ValuefromUser)
during an onClick event, for instance, to obtain a reference to the desired component. Do you have any suggestions on how I can accomplish this?