I have an app where I have an upload component where I can upload a file. It is embedded in the body.component
.
On upload, it should use a function (e.g.
Suppose that I have a ChildComponent
and from that I want to call the method myMethod()
which belongs to ParentComponent
(keeping the original parent's context).
@Component({ ... })
export class ParentComponent {
get myMethodFunc() {
return this.myMethod.bind(this);
}
myMethod() {
...
}
}
@Component({ ... })
export class ChildComponent {
@Input() myMethod: Function;
// here I can use this.myMethod() and it will call ParentComponent's myMethod()
}