我在我的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>发布于 2018-03-04 16:10:21
最有可能的是,Tablesaw是在你从你的服务接收数据之前初始化的。
在组件选择器上添加一个*ngIf="results"。直到你从你的服务中得到数据,Angular才会运行这个组件。
发布于 2018-03-04 15:41:57
在组件选择器上添加一个*ngIf="results"。只有从服务中获得数据,Angular才会运行该组件。
https://stackoverflow.com/questions/49093026
复制相似问题