我有一个Angular2组件在表中显示一些数据.
export class DiagnosisComponent { headers: Array<String> = ["hello world","hello world"]; table: Observable<TableData>; constructor(private eventService: EventService) { this.table = this.eventService.getDiagnosisEvents(); this.table.subscribe(console.log.bind(console)); } }
这是TableData类
export class TableData { content: Array<any>; paging: Paging; constructor(obj: any) { this.paging = { size: obj.size,totalElements: obj.totalElements,currentPage: 1 }; this.content = obj.content; } } export interface Paging { size: number; totalElements: number; currentPage: number; }
现在我想将table.content数组绑定到带有异步管道的* ngFor.我的问题是我需要获取嵌套数据,而不是TableData本身.
<div class="row"> <vpscout-filter></vpscout-filter> <table class="table"> <thead> <tr><th *ngFor="let header of headers">{{header | translate}}</th></tr> </thead> <tbody> <tr *ngFor="let row of table | async "> <td>test</td> </tr> </tbody> </table> </div>
将* ngFor更改为< tr * ngFor =“let table of table | async”>不起作用.