角度数据将不会加载到表中

时间:2019-09-22 15:06:10

标签: angular

我正在尝试将数据加载到学校作业的表中,但不会加载,它仅显示表头。我们大约在2周前开始使用angular,所以我仍然是菜鸟,可能在这里犯了一个愚蠢的错误。请帮帮我!

这是我的桌子:

<table>
<thead>
<tr>
  <th>Title</th>
  <th>Start</th>
  <th>End</th>
  <th>Participation Fee</th>
  <th>Max participants</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let event of aEvents">
  <td>{{ event.title }}</td>
  <td>{{ event.start }}</td>
  <td>{{ event.end }}</td>
  <td>{{ event.participationFee }}</td>
  <td>{{ event.maxParticipants }}</td>
</tr>
</tbody>
</table>

这是我组件的.ts文件:

import {Component, OnInit} from '@angular/core';
import {AEvent} from "../../../models/a-event";

@Component({
  selector: 'app-overview1',
  templateUrl: './overview1.component.html',
  styleUrls: ['./overview1.component.css']
})
export class Overview1Component implements OnInit {

  public aEvents: AEvent[] = [
    new AEvent("event1", new Date(2019, 11, 5), new Date(2019, 11, 5), 10, 10),
    new AEvent("event2", new Date(2019, 11, 5), new Date(2019, 11, 5), 10, 10),
    new AEvent("event3", new Date(2019, 11, 5), new Date(2019, 11, 5), 10, 10),
    new AEvent("event4", new Date(2019, 11, 5), new Date(2019, 11, 5), 10, 10),
    new AEvent("event5", new Date(2019, 11, 5), new Date(2019, 11, 5), 10, 10),
    new AEvent("event6", new Date(2019, 11, 5), new Date(2019, 11, 5), 10, 10),
    new AEvent("event7", new Date(2019, 11, 5), new Date(2019, 11, 5), 10, 10),
    new AEvent("event8", new Date(2019, 11, 5), new Date(2019, 11, 5), 10, 10),
    new AEvent("event9", new Date(2019, 11, 5), new Date(2019, 11, 5), 10, 10)
  ];

  constructor() {

  }

这是AEvent模型的.ts:

export class AEvent {
  title: string;
  start: Date;
  end: Date;
  description: string;
  status: AEventStatus;
  IsTicketed: Boolean;
  participationFee: number;
  maxParticipants: number;

  constructor(title: string, start: Date, end: Date, participationFee: number, maxParticipants: number){
    this.title = title;
    this.start = start;
    this.end = end;
    this.participationFee = participationFee;
    this.maxParticipants = maxParticipants;
  }
}

我不知道我在做什么错,真的很烦它没有加载。

0 个答案:

没有答案
相关问题