我正在寻找能够从AngularJS中的变量渲染javascript函数的方法。下面的Javascript代码将来自JSON对象,我想将其作为HTML呈现给视图。我尝试使用$ sce和ng-bind-html但它会产生错误。
<script>
(function() {
var useSSL = 'https:' == document.location.protocol;
var src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
document.write('<scr' + 'ipt src="' + src + '"></scr' + 'ipt>');
})();
</script>
<script>
googletag.cmd.push(function() {
var leaderboardink = googletag.sizeMapping().
addSize([992, 0], [[970, 90], [728, 90], [300, 250], [1, 1]]). //desktop
addSize([768, 0], [[300, 250], [728, 90], [1, 1]]). //tablet
addSize([320, 0], [[320, 50], [320, 100], [300, 250], [1, 1]]). //mobile
addSize([0, 0], [[320, 50], [1, 1]]). //other
build();
googletag.defineSlot('/61022833/Leaderboard2_INK', [728, 90], 'div-gpt-ad-123456789-0').defineSizeMapping(leaderboardink).addService(googletag.pubads());
googletag.pubads().enableSyncRendering();
googletag.enableServices();
});
</script>
<!-- /61022833/Leaderboard2_INK -->
<div class="gads-contents-1 center">
<div id='div-gpt-ad-123456789-0' style='height:90px; width:728px;'>
<script>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-123456789-0'); });
</script>
</div></div>
我尝试使用$ sce进行操作,但它失败了,因为它有注释并附加。