In my Angular app I have a component called Component1
with selector component-1
, and it's template contains a nested instance of itself:
<div>
<component-1></component-1>
</div>
So the parent Component1
contains a child Component1
.
My Goal:
Component1
contains a method method1()
. I want to call the child component's method1
from the parent component. Something like this.child.method1()
.
What I've Tried:
In the component I get child
with the following code: @ViewChild(Component1) child: Component1;
. If I do console.log(this.child)
I get an object that contains all the @Input
and @Output
values from Component1
, but not the methods like method1()
.
What I Want To Know:
How do I access this.child.method1()
?