In Javascript the following code works as expected:
$("#field").click(eventHandler);
function eventHander() {
invokeClassMethod();
// do other stuff
}
I tried this in Typescript and I get an error because it appears the context of "this" has changed to something that's not my class.
$("#field").click(this.eventHandler);
eventHandler() {
this.invokeClassMethod();
// do other stuff
}
gives me an error because "invokeClassMethod" is undefined.
I'm new to Typescript so can somebody please tell me what's wrong and how to fix it?