Call Javascript Method Variable Loses 'this'
I've created a simple pointer to a method like so: export class SmbwaService { getExistingArsByLab(labId: number): Observable { this.otherMethod();
Solution 1:
Use Function.bind
to obtain a function reference that's bound to a particular value of this
:
method = this.service.getExistingArsByLab.bind(this.service)
method(2)
Post a Comment for "Call Javascript Method Variable Loses 'this'"