From 0663b309b99cb98629390a6f58424ed671007eec Mon Sep 17 00:00:00 2001 From: tombatossals Date: Thu, 9 Jan 2014 11:26:45 +0100 Subject: [PATCH] fix(paths): Solved a bug on the scope watching of the paths attribute. Thanks to @lukasz-zak for reporting and point the solution here: https://github.com/tombatossals/angular-leaflet-directive/pull/230 --- src/directives/paths.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/directives/paths.js b/src/directives/paths.js index 0f85ecf5..47ab54d6 100644 --- a/src/directives/paths.js +++ b/src/directives/paths.js @@ -34,17 +34,17 @@ angular.module("leaflet-directive").directive('paths', function ($log, leafletDa }, true); }; - scope.$watch("paths", function (newPaths) { + leafletScope.$watch("paths", function (newPaths) { // Create the new paths - for (var new_name in newPaths) { - if (!isDefined(leafletPaths[new_name])) { - var newPath = createPath(new_name, newPaths[new_name], defaults); + for (var newName in newPaths) { + if (!isDefined(leafletPaths[newName])) { + var newPath = createPath(newName, newPaths[newName], defaults); // Listen for changes on the new path if (isDefined(newPath)) { - leafletPaths[new_name] = newPath; + leafletPaths[newName] = newPath; map.addLayer(newPath); - watchPathFn(newPath, new_name); + watchPathFn(newPath, newName); } } }