I have developed a basic pointer to a method like this:
export class SmbwaService {
getExistingArsByLab(labId: number): Observable<SmwbaAr[]> {
this.otherMethod();
}
otherMethod(): void {
}
}
let method: (x: number) => Observable<SmbwaAr[]>;
method = this.service.getExistingArsByLab;
method(12);
It runs smoothly in terms of calling the getExistingArsByLab
method. However, I encounter an error when it attempts to call otherMethod
because:
Cannot read property otherMethod of undefined.
What is the correct way to handle this? In my actual code, method
is assigned to different methods based on certain conditions.