I'm learning TypeScript and I'm trying to add a click event on an image. There are no errors in the console and the program runs ok in the browser, but I cannot trigger the click event.
Here's my code:
private spinner: HTMLImageElement = new Image();
//Also tried to initialise like this:
//private spinner: HTMLImageElement;
//this.spinner = document.createElement("img");
this.spinner.src = "graphics/image_name.png"
this.spinner.addEventListener("click", this.test);
//Also tested this:
//this.spinner.onclick = this.test;
Any help would really be appreciated, because I can't find anything online that explains what I'm doing wrong.