显示来自AngularJS的Google Maps iFrame
Show Google Maps iFrame from AngularJS
我构建了一个wordpress插件,用户可以在其中插入谷歌地图代码,如下所示:
<iframe src="https://www.google.com/maps/embed?pb=xxxxx" width="100%" height="100%" frameborder="0" style="border:0"></iframe>
这段代码存储在WP数据库中,我尝试从我的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>
但没有任何结果。
还有其他办法吗??请帮助我,谢谢
可能你需要的是 sce,因为我想你的 iframe 不被接受为受信任的 HTML。
因此,在将 sce 包含在您的控制器中后,例如
app.controller("MainController", ['$scope', '$http','$sce', function($scope, $http, $sce){
,你会做的
$scope.maps = $sce.trustAsHtml(mapsdata);
另请参阅此问题/答案。
此外,对于您确定可以"安全"显示的其他 HTML 数据,您可以使用以下过滤器:
app.filter('unsafe', function($sce) {
return function(val) {
return $sce.trustAsHtml(val);
};
});
您可以将其与
ng-bind-html="yourHTMLdataVariable | unsafe"
相关文章:
- 单击超链接时,如何使用Google Maps API v3缩放地图
- 使用Google Maps API向标记添加多个字符
- Google Maps API OverlayView()在AngularJS指令中不起作用
- 使用Google Maps API驱动时间多边形
- 使用Google Maps JavaScript API v3和Geocoding API映射多个位置
- 在for循环中使用多维数组设置google.maps.Marker图标
- 可扩展的画布作为Google Maps Javascript API中的覆盖
- 在自动完成中使用Google Maps Places API;API不工作
- google.maps.event.addDomListener(window, 'load', fun
- 根据PHP中数组的长度在Google Maps API中循环遍历标记
- 加载Google MAPS API v3的JSON数据
- 如何使用Dojo引用Google Maps事件中的包含类
- Javascript:Google Maps API:如果地图加载在隐藏容器中,则为空白地图
- 如何在Ionic/Codova应用程序中保护我的Google Maps Javascript V3 API密钥
- 来自JSON数组的Google Maps API生成器
- Google Maps JavaScript API v3:getDetails(请求,回调),用于多个位置
- "现代的“;在Google Maps JS API v3上使用字母标记
- Google Maps Javascript v3 自定义控件子类化标准控件
- Google Maps panTo conflicts with addListener
- 来自plugin.google.maps(不是com.google.maps)的标记不会改变其位置