我在我的 Angular 5 项目中使用 Tablesaw,但是当我从服务中获取我的表数据但它使用静态数据时它不起作用。
export class MmrParticipationListComponent implements OnInit {
pid; mid; participationList; approversList = [];
constructor(private activatedRoute: ActivatedRoute, private programService:
ProgramService) { }
ngOnInit() {
this.activatedRoute.queryParams.subscribe(params => {
this.pid = +params['pid'];
this.mid = +params['mid'];
this.programService.getParticipationList(this.pid, this.mid, 0).subscribe(a => {
this.participationList = a;
this.programService
.getParticipationListPerEachGroup(this.pid, this.mid, this.participationList.FillRepeater[0].MMRPTID)
.subscribe(b => { this.approversList = b;}
);
});
});
}
}
<table *ngIf="approversList" class="tablesaw tablesaw-stack table table-
hover table-custom" data-tablesaw-mode="stack">
<thead>
<tr> <th>Role</th> <th>Name</th> </tr>
</thead>
<tbody>
<tr *ngFor="let item of approversList">
<td>{{item.Role}}</td> <td>{{item.Name}}</td>
</tr>
</tbody>
</table>