【发布时间】:2014-12-17 08:18:03
【问题描述】:
我已经构建了一个 wordpress 插件,用户可以在其中插入像这样的谷歌地图代码:
<iframe src="https://www.google.com/maps/embed?pb=xxxxx" width="100%" height="100%" frameborder="0" style="border:0"></iframe>
此代码存储在 wp-database 中,我尝试从我的 angularjs 代码中获取它..
getMaps();
function getMaps(){
$http.post("wp-content/themes/koplan/pages/getMaps.php").success(function(mapsdata){
$scope.maps = mapsdata;
});
};
我的问题是:如何在前端 php/html 中绑定/渲染 iframe?我试过<div ng-bind-html=maps>,但什么也没出现。
还有什么办法吗??请帮助我,谢谢
【问题讨论】:
-
为什么不能绑定?它说什么?
-
@trainoasis 在控制台中没有警告,如果我使用 {{}} 渲染,数据(iframe 标签)正在查看,但是如果我使用 ng-bind-html 渲染,地图仍然是空白的。我只是想要转换 iframe 标签以使用 angular 查看地图
-
可能你只需要使用 trustashtml 吗? docs.angularjs.org/api/ng/service/$sce#methods_trustashtml
标签: javascript angularjs wordpress google-maps iframe