我正在使用 Bing Maps AJAX 控件来显示地图。我已经为我想放在地图上的图钉创建了一个 Angular 指令:
app.directive('myPin', function(){
return {
restrict: 'E',
templateUrl: '<p>{{title}}</p>'
}
})
在我的 Angular 控制器中,我设置了地图,然后将 (a) Pin(s) 添加到它,如下所示:
// Define the title for the Pin
$scope.title = 'Test title';
// Define the location and the options for the Pin
var location = new Microsoft.Maps.Location(52.48, 13.42);
var pushpinOptions = {
width: null,
height: null,
htmlContent: '<my-pin></my-pin>'
};
// Push the Pin onto the map
map.entities.push(new Microsoft.Maps.Pushpin(location, pushpinOptions));
不幸的是,但很明显,我的自定义图钉没有显示在地图上,因为“htmlContent”部分是由 Bing 服务动态注入到 DOM 中的。我已经尝试了很多 Angular 的 $compile 服务,但我不知道如何让它工作......