【发布时间】:2016-04-27 00:30:24
【问题描述】:
是否可以在 API 生成的ul 列表中添加带有 src 参数的 iframe 链接?
真的是网址集中。我有提供数据的 API,我希望将其显示为带有 iframe 的列表。
我有这个代码模板:
(...)
var getTemplate = function(contentType) {
var template = '<ul>'
+'<li ng-repeat="li in item.list" class="[[li.class]]">'
+'<iframe width="100%" height="300"'
+'ng-src="https://myserver.com/?id=[[li.mydata]]"'
+'</iframe>'
+'</li></ul>';
return template;
};
(...)
interpolate 设置为 [[ 和 ]]
SCE 安全值得信赖
.config(function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist([
'self',
'https://myserver.com/**',
])
})
当添加到模板<h4>[[li.mydata]]</h4> 时结果可见,但当添加到 iframe ng-src - 失败并出现此错误
https://docs.angularjs.org/error/$interpolate/noconcat?p0=
任何想法或建议如何解决这个问题?
【问题讨论】:
标签: angularjs templates iframe