onYouTubeIframeAPIReady on Angular2 can't find name 'YT'
问题 I'm trying to insert the YouTube embed API on my angular 2 project, built with angular cli. I get a "can't find name 'YT'" when I try the approach commented on this question: onYouTubeIframeAPIReady not firing on angular2 web app My service code looks like this: loadAPI() { var tag = document.createElement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);