【发布时间】:2016-09-18 02:21:45
【问题描述】:
我正在尝试在谷歌地图信息窗口中添加一个模板,但是当我尝试编译内容并将其设置为 infowindow.content 时,它会显示为评论。我正在使用版本1.2.27。
var infowindow = new google.maps.InfoWindow();
var content = '<div id="iw_c" ng-include="\'/infowindow.html\'"></div>';
var compiled = $compile(content)(scope);
infowindow.setContent(compiled[0]);
console.log(infowindow.content);
这是console.log(infowindow.content)的输出
<!-- ngInclude: '/infowindow.html' -->
已经尝试过this question中的解决方案。
【问题讨论】:
-
您需要将路径用单引号括起来。试试这个
<div ng-include src="'infowindow.html'"></div> -
(\)是从内容(')中转义(')。但即使我输入'<div ng-include=""></div>',我也会得到相同的输出。 -
问题出在版本上。在 1.1.5 中工作正常
标签: angularjs