title: AngularJS and adsense
body: <p>I want to add Google Adsense to my angular app, I found a working example <a href="https://stackoverflow.com/questions/17416992/angular-js-adsense">here</a>. </p>
  
  <p>The problem is that I cannot add the html in my template because I'm loading templates in a script tag (<code>&lt;script type="text/ng-template"....</code>) and the <code>script</code> tag of adsense breaks the template.</p>
  
  <p>I tried moving the template to the directive:</p>
  
  <pre><code>app.directive('Adsense', function() {
    return {
      restrict: 'A',
      transclude: true,
      replace: true,
      template: '&lt;div&gt;&lt;script type="text/javascript" async="async" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"&gt;&lt;/script&gt;' +
                '&lt;ins class="adsbygoogle" style="display: inline-block; width: 234px; height: 60px;" ' +
                'data-ad-client="ca-pub-xxxxx" data-ad-slot="xxxxx"&gt;&lt;/ins&gt;' +
                '&lt;script type="text/javascript"&gt;(adsbygoogle = window.adsbygoogle || []).push({});&lt;/script&gt;&lt;/div&gt;',
      link: function ($scope, element, attrs) {}
    }
  })
  </code></pre>
  
  <p>But the javascript is not executed when the directive is set up (which seems to be the wanted behavior <a href="https://stackoverflow.com/questions/14676695/angularjs-template-inner-js-not-execute">AngularJS template. Inner JS not execute</a>). There's another way?</p>