From e69a1124ce95d552140d05d3b49fb5cd90f8d074 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Tue, 16 Apr 2013 14:51:51 +0300 Subject: [PATCH] check for google object before binding events inside an ng-repeat, when the collection is empty the watch still gets triggered, but with undefined as value. We shouldn't bind events in this case. --- ui-map.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui-map.js b/ui-map.js index 89a0e4f..8b73981 100644 --- a/ui-map.js +++ b/ui-map.js @@ -92,7 +92,9 @@ restrict: 'A', link: function (scope, elm, attrs) { scope.$watch(attrs[directiveName], function (newObject) { - bindMapEvents(scope, events, newObject, elm); + if (newObject) { + bindMapEvents(scope, events, newObject, elm); + } }); } }; @@ -122,4 +124,4 @@ mapOverlayDirective('uiMapGroundOverlay', 'click dblclick'); -})(); \ No newline at end of file +})();