I'm trying to call a public method on a child component from my parent component but I'm getting the error
core.js:5967 ERROR TypeError: this.foo.bar is not a function
which I understand th is is because even though my ViewChild is of type ChildComponent it's not actually a ChildComponent, it's just the same shape as a ChildComponent but ultimately is just a plain old JS object.
So how do I call a public method on a child component?
My code looks like:
parent.html
<app-child-component #childComponent></app-child-component>
parent.ts
export class ParentComponent implements OnInit {
{
    @ViewChild('childComponent') childComponent:ChildComponent;
    ngOnInit(): void {
        this.childComponent.foo(); // ERROR TypeError: this.childComponent.foo is not a function
    }
}
childComponent.ts
export class ChildComponent implements OnInit {
{
    public foo(): void
    {
        // ...
    }
}
 
    