Skip to content

Commit 3e508bd

Browse files
committed
Merge pull request allenhwkim#522 from galenmarchetti/feature/parse-ids-with-lazy-init
parsing handlebars expressions in ids before lazy init
2 parents d22db1e + e166601 commit 3e508bd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

controllers/map-controller.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,14 @@
231231
vm.eventListeners = {};
232232

233233
if (options.lazyInit) { // allows controlled initialization
234-
vm.map = {id: $attrs.id}; //set empty, not real, map
234+
// parse angular expression for dynamic ids
235+
if (!!$attrs.id && $attrs.id.startsWith('{{') && $attrs.id.endsWith('}}')) {
236+
var idExpression = $attrs.id.slice(2,-2);
237+
var mapId = $parse(idExpression)($scope);
238+
} else {
239+
var mapId = $attrs.id;
240+
}
241+
vm.map = {id: mapId}; //set empty, not real, map
235242
NgMap.addMap(vm);
236243
} else {
237244
vm.initializeMap();

0 commit comments

Comments
 (0)