我在YouTube上关注这个教程,它基本上是一个包含你喜欢的音乐的表格,但教程结束了.
它正在使用Angular2,并且一切正常,但是绅士离开它时,它只是在控制台中使用以下代码显示视频的构造函数:
*Playlist.Component.Ts:
export class PlaylistComponent{
onSelect(vid:Video) {
console.log(JSON.stringify(vid)); } }
Run Code Online (Sandbox Code Playgroud)
*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>
Run Code Online (Sandbox Code Playgroud)
*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, …Run Code Online (Sandbox Code Playgroud) App.Module.ts
import { AngularFireDatabase } from 'angularfire2/database';
imports: [
AngularFireDatabase
]
Run Code Online (Sandbox Code Playgroud)
出于某种原因,当我不需要时,它一直要求我添加一个@NgModule注释.我是Firebase的新手.
我已经尝试将其添加到我的tsconfig.json文件中以查看它是否可以获取angularfire2模块但仍然没有运气:
"paths": {
"@angular/*": [
"../node_modules/@angular/*"
],
Run Code Online (Sandbox Code Playgroud)