Skip to content

Commit 90064be

Browse files
authored
Fix heatmap-layer.js nested prop
Allows to the directive access to a nested property. This problem happens when we are using a nested property like 'data.map.heathData' or more commonly when we are using the syntax 'controllerAs', adding a 'vm' variable or similar. fix: allenhwkim#835
1 parent db3d95d commit 90064be

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

directives/heatmap-layer.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* set options
3232
*/
3333
var options = parser.getOptions(filtered, {scope: scope});
34-
options.data = $window[attrs.data] || scope[attrs.data];
34+
options.data = $window[attrs.data] || parseScope(attrs.data, scope);
3535
if (options.data instanceof Array) {
3636
options.data = new google.maps.MVCArray(options.data);
3737
} else {
@@ -46,6 +46,13 @@
4646
console.log('heatmap-layer options', layer, 'events', events);
4747

4848
mapController.addObject('heatmapLayers', layer);
49+
50+
//helper get nexted path
51+
function parseScope( path, obj ) {
52+
return path.split('.').reduce( function( prev, curr ) {
53+
return prev[curr];
54+
}, obj || this );
55+
}
4956
}
5057
}; // return
5158
}]);

0 commit comments

Comments
 (0)