title: Scope of ng-click on a dynamically created button not working on Google Map
body: <p>I am trying to click on a button that was dynamically created when I click on the Google Map's marker by using InfoWindow, and there is nothing triggering it. <a href="https://developers.google.com/maps/documentation/javascript/examples/infowindow-simple" rel="nofollow">This</a> is the link that I followed. What am I missing here? Below are my code.</p>
  
  <p>JS</p>
  
  <pre><code>$scope.openMap = function(test){
      console.log(test);
  }
  
  $scope.addMarker = function(location) {
      var marker = new google.maps.Marker({
          position: location,
          map: map
      });
      var contentString = 'Lat: '+location.lat+ ' lng: '+location.lng+
                          '&lt;button ng-click="openMap("testing")"&gt;Map&lt;/button&gt;';
      var infowindow = new google.maps.InfoWindow({
          content: contentString
      });
      marker.addListener('click', function() {
          infowindow.open(map, marker);
      });
      markers.push(marker);
  }
  </code></pre>
  
  <p>The function addMarker will add a new marker location on the map. This function works and as noticed, the variable contentString was added to the attribute content in infowindow. The problem is $scope.openMap is not able to be called. </p>