Skip to content

Instantly share code, notes, and snippets.

@mugan86
Last active June 13, 2020 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mugan86/0c0226b244646c3863eef0c0eab12287 to your computer and use it in GitHub Desktop.
Save mugan86/0c0226b244646c3863eef0c0eab12287 to your computer and use it in GitHub Desktop.
Componente principal con el iframe para usar el reproductor de Youtube
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit{
ngOnInit() {
// Este código carga el reproductor de la API en un iframe de manera asíncrona, siguiendo las instrucciones:
// https://developers.google.com/youtube/iframe_api_reference#Getting_Started
const tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
document.body.appendChild(tag);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment