简体   繁体   中英

Execute Javascript Advertise Script within AngularJS partial

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>

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.

Any help is appreciated.

Greets, Marc

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.
});

Hope this helps,

Patrick

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM