Whenever I attempt to pass a service function as a parameter to another function, an error 'Cannot read properties of undefined myService' occurs during execution. However, calling this.myService.method() individually works perfectly fine without any issues. What could be causing this problem?
Here is the TypeScript file:
constructor(private myService: MyService)
function1(): void {
this.function2(this.myService.method)
}
function2(f: Function)
{
f();
}