title: How to render script tags in AngularJS
body: <p>I am looking for ways to be able to render a javascript function from a variable in AngularJS. Javascript code below will come from a JSON object and I'd like to render it to the view as HTML. I tried using $sce and ng-bind-html but it generates an error.  </p>
  
  <pre><code>  &lt;script&gt;
    (function() {
      var useSSL = 'https:' == document.location.protocol;
      var src = (useSSL ? 'https:' : 'http:') +
          '//www.googletagservices.com/tag/js/gpt.js';
      document.write('&lt;scr' + 'ipt src="' + src + '"&gt;&lt;/scr' + 'ipt&gt;');
    })();
  &lt;/script&gt;
  
  &lt;script&gt;
    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();
    });
  &lt;/script&gt;
  
  &lt;!-- /61022833/Leaderboard2_INK --&gt;
  &lt;div class="gads-contents-1 center"&gt;
  &lt;div id='div-gpt-ad-123456789-0' style='height:90px; width:728px;'&gt;
  &lt;script&gt;
  googletag.cmd.push(function() { googletag.display('div-gpt-ad-123456789-0'); });
  &lt;/script&gt;
  &lt;/div&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I tried doing it using $sce but it is failing as it has comments and appends.</p>