我在YouTube上关注这个教程,它基本上是一张包含你喜欢的音乐的表格,但教程结束了。如何在Angular2中嵌入YouTube视频?
它使用Angular2,一切工作正常但是当绅士离开它,它只是显示在视频中使用此代码控制台的构造:
* Playlist.Component.Ts:
export class PlaylistComponent{
onSelect(vid:Video) {
console.log(JSON.stringify(vid)); } }
* Playlist.Component.html:
<table class="table table-hover">
<thead>
<tr>
<td>ID</td>
<td>Title</td>
<td>Description</td>
</tr>
</thead>
<tbody>
<tr *ngFor="#v of videos" (click)="onSelect(v)">
<td>{{ v.id }}</td>
<td>{{ v.title }}</td>
<td>{{ v.desc }}</td>
</tr>
</tbody>
</table>
个* App.Component.Ts:
import {Component} from 'angular2/core';
import {Config} from './config.service';
import {Video} from './video';
import {PlaylistComponent} from './playlist.component';
@Component({
selector: 'my-app',
templateUrl: 'app/ts/app.component.html',
directives: [PlaylistComponent]
})
export class AppComponent {
mainHeading = Config.MAIN_HEADING;
videos:Array<Video>;
constructor() {
this.videos = [
new Video(1, "The 1975 - Somebody Else", "Bimd2nZirT4", "Calm."),
new Video(2, "Killswitch Engage - Holy Diver", "NR7dG_m3MsI", "Hell Yeah!")
]
}
}
*最后的Video.ts:
export class Video {
id: number;
title: string;
videoCode: string;
desc: string;
constructor(id: number, title: string, videoCode: string, desc: string){
this.id = id;
this.title = title;
this.videoCode = videoCode;
this.desc = desc;
}
}
我将如何得到它实际上是嵌入在浏览器中,一旦你在YouTube视频点击桌子?
干杯伙计,现在排序! :) –