I'm receiving a JSON object as Data source for my markers. After that I'm binding Click/Close functions for each marker
Plunk: http://plnkr.co/edit/A9IbIFpj3d9tH6z9NYjf?p=preview
angular.forEach(tmp, function(value, key){
value.onClick = function(){
console.log("Clicked!");
$scope.selected.show = false;
$scope.selected = value;
$scope.selected.show = !$scope.selected.show;
$scope.$apply();
};
value.CloseClick = function() {
$scope.selected.show = false;
console.log("CloseClicked");
$scope.$apply();
};
this.push(value);
}, $scope.markers);
and then drawing markers on a Google Map using Angular Google Maps
<ui-gmap-google-map center='map.center' zoom='map.zoom'>
<ui-gmap-markers models="markers" fit="true" coords="'self'" click="onClick">
</ui-gmap-markers>
<ui-gmap-window coords="selected" show="selected.show" closeClick="closeClick"><div>aga</div></ui-gmap-window>
</ui-gmap-google-map>
but when I click on a marker, the function onClick does not trigger. I'm new in Angular.js, but it seems I have an issue with it (or maybe worse for me - with JavaScript itself), not with Angular Google Maps, but I'm not sure. Thanks for any help.
[UPDATE] Problem solved by using click="'onClick'"
instead of click="onClick"
You could also add parentheses () to the methods, e.g. click="onClick()"