我一直试图从Angular Material 实现这个表的例子而没有运气
我不明白我做错了什么,我的REST端点提供的数据在控制台输出上清晰可见.
我的怀疑是,当表格被渲染时,数据可能还没有完全加载.任何帮助表示赞赏,谢谢!
lap.component.ts
import {Component, OnInit, ViewChild} from '@angular/core';
import {MatPaginator, MatSort, MatTableDataSource} from '@angular/material';
import {Router} from '@angular/router';
import {LapService} from '../shared/services/lap.service';
import {Lap} from '../shared/model/lap.model';
@Component({
selector: 'app-lap',
templateUrl: './lap.component.html',
styleUrls: ['./lap.component.css']
})
export class LapComponent implements OnInit {
displayedColumns = ['id', 'year', 'lap', 'shortcut flag', 'start place', 'destination place', 'length', 'height difference'];
dataSource: MatTableDataSource<Lap>;
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
constructor(public rest: LapService, private router: Router) {
}
ngOnInit() {
this.dataSource = …Run Code Online (Sandbox Code Playgroud)