angular template in leaflet popup

1,784 views
Skip to first unread message

Eamonn O'Connell

unread,
Jan 24, 2013, 10:52:58 AM1/24/13
to ang...@googlegroups.com
With the leaflet map api, you can specify a popup for a marker very easily

    var marker = new L.Marker([latitude, longitude]);
    var popupContent = "<h1>Hi there!</h1>"
    marker.bindPopup(popupContent)

as you can see it accepts HTML. I wonder if any has tried or thought about how that popupContent could come from an angular template. I only know of how to use a template when it is part of a routes definition.

Валерий Озарничук

unread,
Jan 25, 2013, 4:22:24 AM1/25/13
to ang...@googlegroups.com
U can use $compile and $http to get a template.
For example:

function anyCtrl($scope, $compile, $http, $element){
$http('/get/template.html').success(function(r){
$element.html(r);
$compile($element)($scope);
});
}

Eamonn O'Connell

unread,
Jan 25, 2013, 12:13:25 PM1/25/13
to ang...@googlegroups.com
thanks!

Julia Jacobs

unread,
Nov 11, 2013, 1:48:36 PM11/11/13
to ang...@googlegroups.com
I tried to inject an html template as a string to the message param for the Angular Leaflet Directive

but I gave up.
Reply all
Reply to author
Forward
0 new messages