{"action":"closed","issue":{"url":"https://api.github.com/repos/tombatossals/angular-leaflet-directive/issues/969","labels_url":"https://api.github.com/repos/tombatossals/angular-leaflet-directive/issues/969/labels{/name}","comments_url":"https://api.github.com/repos/tombatossals/angular-leaflet-directive/issues/969/comments","events_url":"https://api.github.com/repos/tombatossals/angular-leaflet-directive/issues/969/events","html_url":"https://github.com/tombatossals/angular-leaflet-directive/issues/969","id":109227567,"number":969,"title":"programatically load template for popup on marker click event","user":{"login":"mikedevita","id":2991640,"avatar_url":"https://avatars.githubusercontent.com/u/2991640?v=3","gravatar_id":"","url":"https://api.github.com/users/mikedevita","html_url":"https://github.com/mikedevita","followers_url":"https://api.github.com/users/mikedevita/followers","following_url":"https://api.github.com/users/mikedevita/following{/other_user}","gists_url":"https://api.github.com/users/mikedevita/gists{/gist_id}","starred_url":"https://api.github.com/users/mikedevita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikedevita/subscriptions","organizations_url":"https://api.github.com/users/mikedevita/orgs","repos_url":"https://api.github.com/users/mikedevita/repos","events_url":"https://api.github.com/users/mikedevita/events{/privacy}","received_events_url":"https://api.github.com/users/mikedevita/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-01T04:28:32Z","updated_at":"2015-10-01T14:08:53Z","closed_at":"2015-10-01T14:08:53Z","body":"Ive managed to piece together the following code and its working except for the popup template.. and im not sure the best way to go about this..\r\n\r\nI am building a 4x4 trail system thats open source and has a REST api built off leaflet for the frontend. Because its going to be state wide there are going to be a TON of trails potentially. As such The markers are placed with as little data as possible, lat, lng, id, difficulty. On click I want to programmatically load up that trail's info, build out the template and open a popup. \r\n\r\nHere is the code i have so far that i've pieced together from other questions asked on here.. I just cant figure out the template generation..\r\n\r\n```javascript\r\n  var showPopup = function(marker_id) {\r\n    var marker = $scope.map.markers[marker_id];\r\n    // this is a snippet of how i was doing it.. i was pushing into the $scope.map.markers the template.. that seems heavy\r\n    // message: '<div ng-include src=\"\\'app/components/map/popup.tpl.html\\'\"></div>',\r\n    // compileMessage: true,\r\n    // getMessageScope: function() {\r\n    //   $scope.rating = rating;\r\n    //   $scope.trail = trail;\r\n    //   return $scope;\r\n    // },\r\n    Trail.findOne(marker.trailId)\r\n    .then(function(trail){\r\n\r\n      var content = '<div ng-include src=\"\\'app/components/map/popup.tpl.html\\'\"></div>';\r\n      var latLng   = [marker.lat, marker.lng];\r\n      var popup    = L.popup({ className : 'custom-popup' }).setContent(content).setLatLng(latLng);\r\n      leafletData.getMap().then(function(map) {\r\n        popup.openOn(map);\r\n      });\r\n    });\r\n  };\r\n\r\n  $scope.$on('leafletDirectiveMarker.click', function(e, args){\r\n      showPopup(args.modelName);\r\n  });\r\n```"}}