执行JavaScript内AngularJS部分广告脚本 [英] Execute Javascript Advertise Script within AngularJS partial
问题描述
我有一个web应用,我需要放置一些广告的脚本在我的一些谐音的。这些脚本是这样的:
I have a webapplication where I need to place some Advertise-Scripts in some of my partials. The scripts are like:
<script type="text/javascript" src="http://www.googletagservices.com/tag/js/gpt.js">
googletag.pubads().definePassback('/XYZ/TEST_allAdformats', [300, 250]).display();
</script>
的问题是,当前的脚本心不是执行。当我将它移到index.html的,一切正常。但是,这不会解决我的问题,因为我需要把它在我的内部分的特定位置。
The problem is, that currently the script isnt executed. As soon as I move it to index.html, everything works as expected. But that won't solve my problem, because I need to place it at a specific position within my partial.
任何帮助是AP preciated。
Any help is appreciated.
映入眼帘,马克
推荐答案
我曾在我试图在局部视图月底执行JS文件同样的问题。
我加载$ viewContentLoaded到控制器的部分(或指令)。所有你需要在你的控制器声明注射$范围对象。
这似乎修复它,但它可能是一个有点困难,你必须在脚本内容加载到HTML中。
I have had the same problem in which I tried to execute a JS file at the end of partial view. I loaded the $viewContentLoaded into the controller for the partial (or the directive). All you need in the $scope object in your controller declaration for injection. This seemed to fix it, but it may be a little bit harder as you have to load the script contents into the html.
$scope.$on('$viewContentLoaded', function(){
//Do Something Here to load your script and insert it.
});
希望这有助于
帕特里克
这篇关于执行JavaScript内AngularJS部分广告脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!