【发布时间】:2017-11-10 14:30:59
【问题描述】:
让我先说我对 Angular2 很陌生。所以我试图将列表EMPS 加载到我的表中。这是我的 app.component.ts 文件,其中包含我的大部分代码
import { Component } from '@angular/core';
export class Emp {
name: string;
email: string;
office: string;
}
const EMPS: Emp[] = [
{ name: 'test1', email: 'test1@test.com', office: 'NY' },
{ name: 'test2', email: 'test2@test.com', office: 'LA' },
{ name: 'test3', email: 'test3@test.com', office: 'CHA' }
];
@Component({
selector: 'my-app',
template: `
<h1>{{ title }}</h1>
<div *ngFor="let d of data | async">
<table border=1>
<tr>
<td>
<h3>name: {{ d.name }}</h3>
</td>
<td>
<h3>email: {{ d.email }}</h3>
</td>
<td>
<h3>office: {{ d.office }}</h3>
</td>
<td>
</tr>
</table>
</div>
`,
styles: [`
`]
})
export class AppComponent {
title = 'TestTable';
emps = EMPS;
data = this.emps;
}
这是我得到的错误:
我现在很迷茫,不知道该怎么办。谁能帮帮我?
【问题讨论】:
标签: javascript angular html-table