There are times when a parent component needs access to his children. Let’s see how we can handle this with Angular.
Returns the specified elements or directives from the view DOM as QueryList
For example, let’s create a simple
Now let’s use this component multiple times in our
app component and use the
We can use the
@ViewChildren decorator to grab elements from the host view.
@ViewChildren decorator supports directive or component type as parameter, or the name of a template variable.
When the parameter is a component/directive the return value will be the component/directive instance.
... read the whole story at medium.com.