title: Exception in queued GPT command TypeError: Cannot read property 'addService' of null
body: <p>I am using adsesne code in my angularjs application. On the first load of application ads are working fine when I switch content dynamically I get this error. </p>
  
  <p><code>Exception in queued GPT command TypeError: Cannot read property 'addService' of null site:stackoverflow.com</code>.</p>
  
  <p>This is the script which I load inside my div.</p>
  
  <pre><code>&lt;script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"&gt;&lt;/script&gt;
  &lt;script&gt;
    window.googletag = window.googletag || {cmd: []};
    googletag.cmd.push(function() {
      googletag.defineSlot('/28379801/MWBanner320x50', [320, 50], 'div-adlocation').addService(googletag.pubads());
      googletag.enableServices();
    });
  &lt;/script&gt;
  &lt;!-- /28379801/MWBanner320x50 --&gt;
  &lt;div id='div-adlocation' style='width: 320px; height: 50px; margin:auto'&gt;
    &lt;script&gt;
      googletag.cmd.push(function() { googletag.display('div-adlocation'); });
    &lt;/script&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Any possible work around using angularjs?</p>