Angular如何在组件中使用嵌入脚本

时间:2018-12-02 05:21:01

标签: node.js angular typescript twitch

我试图在Angular中设置一种仅在流在线时显示Twitch播放器的方式,因此在Documentation中有以下内联HTML:

<script src= "https://player.twitch.tv/js/embed/v1.js"></script>
<div id="<player div ID>"></div>
<script type="text/javascript">
  var options = {
    width: <width>,
    height: <height>,
    channel: "<channel ID>",
    video: "<video ID>",
    collection: "<collection ID>",
  };
  var player = new Twitch.Player("<player div ID>", options);
  player.setVolume(0.5);
</script>

当然,尽管在Angular Components中我们不能使用