On-tap event, coordinates

(ionic2)

I have an on-tap event on a canvas:
<canvas on-tap="onTap()" .... ></canvas>

I want to now where the user has clicked (coordinates).

I found this: https://forum.ionicframework.com/t/touch-coordinates-touchmove/8971
but the function pointerCoord needs an event argument, which I don’t have (onTap() has no args).
How can I access the current event?

Or is there another way to get the tap coordinates?

I found and (the?) answer myself. Two closely related alternatives:

  1. pass $event in html:
    @Component({
        ...
        template: '<canvas on-tap="onTap($event)" ... </canvas>'
    })
    class XXX {
        ...
        onTap(event): void {
            let x = event.srcEvent.offsetX;
            ...
        }
    }
  1. use $event in javascript:
    @Component({
        ...
        template: '<canvas on-tap="onTap()" ... </canvas>'
    })
    class XXX {
        ...
        onTap(): void {
            let x = $event.srcEvent.offsetX;
            ...
        }
    }

This works, but typescript compilation gives Error TS2304: Cannot find name ‘$event’.

Other suggestions welcome!

Hi have you find how get coordinates on tap ?