Uncaught reference error when calling a function from InfoWindow - Ionic 2/Google Maps Api 3

I am developing an Ionic 2 application using the Javascript Google Maps API.

I added an infowindow and implemented a button on the infoWindow which was to call myFunction() as it is clicked.

I tried the solution in the following question:

I had to make some changes as I am using Ionic and I got a code like this:

addInfoWindow(marker, content){
let infoWindow = new google.maps.InfoWindow({
  content: ' ',
google.maps.event.addListener(marker, 'click', () => {
  infoWindow.setContent('<h4>You are here</h4><button onclick="myFunction()">Click me!</button>');
  infoWindow.open(this.map, marker);


I am getting

Uncaught ReferenceError: myFunction is not defined

Any solution to this one?