class component()
{
Service _service = new Service();
let serviceMethod = isUpdate ? this._service.update :
this._service.create;
serviceMethod(param);
}
class Service
{
update()
{
// Other stuff
// Cannot access this here
this.privatelocalfunc();
}
create()
{
// Other stuff
// Cannot access this here
this.privatelocalfunc();
}
}
I have to conditionally switch between methods as described in the code above. However when I do this, I cannot access the 'this' variable for the service method. Whats the best way to achieve this?