Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question
1  
Your partials are in the same folder that index.html ? Because you use a path in your javascript line. –  R3tep Jul 28 at 14:49
    
No, they are in another folder which is controlled through routes. But that souldnt matter if I load an external JS file? –  marcbaur Jul 28 at 14:50

1 Answer 1

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

share|improve this answer
    
Hi Maxiumus Thanks for your help. I tried your approach but the Advertise is not working like that. Any other suggestions? –  marcbaur Jul 31 at 11:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.