当我从服务中获取数据时,Angular 2 中的 Table Saw 无法正常工作
Tablesaw in Angular2+ not working when I get my data from service
我在我的 Angular 5 项目中使用 Tablesaw,但是当我从服务中获取我的 table 数据但它使用静态数据时它不起作用。
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>
在组件选择器上添加一个 *ngIf="results"
。在您从服务中获得数据之前,Angular 不会 运行 组件。
很可能,Tablesaw 在您从您的服务接收数据之前正在初始化。
在组件选择器上添加 *ngIf="results"
。在您从服务中获得数据之前,Angular 不会 运行 该组件。
我在我的 Angular 5 项目中使用 Tablesaw,但是当我从服务中获取我的 table 数据但它使用静态数据时它不起作用。
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>
在组件选择器上添加一个 *ngIf="results"
。在您从服务中获得数据之前,Angular 不会 运行 组件。
很可能,Tablesaw 在您从您的服务接收数据之前正在初始化。
在组件选择器上添加 *ngIf="results"
。在您从服务中获得数据之前,Angular 不会 运行 该组件。