Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angular 2新增,尝试将数据加载到表中_Javascript_Angular_Html Table - Fatal编程技术网

Javascript Angular 2新增,尝试将数据加载到表中

Javascript Angular 2新增,尝试将数据加载到表中,javascript,angular,html-table,Javascript,Angular,Html Table,首先让我说我对安格拉尔很陌生。因此,我试图将列表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@t

首先让我说我对安格拉尔很陌生。因此,我试图将列表
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;

}
从'@angular/core'导入{Component};
出口级电磁脉冲{
名称:字符串;
电子邮件:字符串;
办公室:字符串;
}
常量Emp:Emp[]=[
{名称:'test1',电子邮件:'test1@test.com,办公室:'纽约'},
{名称:'test2',电子邮件:'test2@test.com办公室:'洛杉矶'},
{名称:'test3',电子邮件:'test3@test.com'办公室:'查'}
];
@组成部分({
选择器:“我的应用程序”,
模板:`
{{title}}
名称:{d.name}
电子邮件:{{d.email}
办公室:{d.office}
`,
风格:[`
`]
})
导出类AppComponent{
title='TestTable';
emps=emps;
data=this.emps;
}
以下是我得到的错误:


我现在很迷茫,不知道该怎么办。有人能帮我吗?

停止在
*ngFor
中使用
async
管道。这应该用于迭代一个可观察的对象。您使用的是“静态”内容,而不是可观察内容。

正是这样!很乐意帮忙!我会补充说,如果你不熟悉可观察物,那么你应该熟悉RxJS。在这个世界上非常有用和重要。