Use the this
with the arrow
function as follows:
class A { public func1() { let sample = () => { this.func2(); } } public func2() { } }
The trick uses the arrow
function because the arrow
function changes the definition of this
as an instance of class
instead of the current scope. You can read more here.
source share