title: onYoutubeIFrameAPIReady only fired once
body: <p>I have an angularjs application where i want to show some youtube videos in a newsfeed.
  I have created a directive to load the player, and my videos load the first time i'm entering a view containing a video. But if i leave the view, and opens i again the video is not loaded.</p>
  
  <p>It seems that the event "onYouTubeIframeAPIReady" is only triggered first time i enter the view.</p>
  
  <p><strong>The view:</strong></p>
  
  <pre><code>        &lt;div bind-html-compile="newsitem.description"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>The newsitem.description is raw html send to the application as json.</p>
  
  <p>so it could look like:</p>
  
  <pre><code>{'this is a video &lt;youtube videoid="myYoutubeVideoId"&gt;&lt;/youtube&gt;'}
  </code></pre>
  
  <p>That is also why im using the bind-html-compile directive.</p>
  
  <p><strong>The directive</strong></p>
  
  <pre><code>.directive('youtube', function($window) {
  return {
      restrict: "E",
  
      scope: {
          videoid: "@"
      },
  
      template: '&lt;div&gt;&lt;/div&gt;',
  
      link: function(scope, element, attrs) {
          var tag = document.createElement('script');
          tag.src = "https://www.youtube.com/iframe_api";
          var firstScriptTag = document.getElementsByTagName('script')[0];
          firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  
          var player;
  
          $window.onYouTubeIframeAPIReady = function() {
              player = new YT.Player(element.children()[0], {
                   playerVars: {
                      autoplay: 0,
                      html5: 1,
                      theme: "light",
                      modesbranding: 1,
                      color: "white",
                      iv_load_policy: 3,
                      showinfo: 0,
                      controls: 0,
                      rel: 0,
                  },
                  videoId: scope.videoid
              });
          };
      }
  }})
  </code></pre>
  
  <p>When i console.log from onYoutubeIFrameAPIReady i only get output the first time..
  So im thinking that the event is somehow triggered before the function is ready, but i can't realy figure it out.</p>
  
  <p>Any ideas?</p>