【发布时间】:2021-02-21 19:50:32
【问题描述】:
从 API 获取的数据没有显示在屏幕上,但我正在控制台中获取数据。
这是 .ts 文件。
export class VisibilityComponent implements OnInit {
check = false;
pmDetails1: IEmployee[];
constructor( private userService: UserService) {
this.pmDetails1 = [];
}
ngOnInit() {
this.userService.getAllEmployee().subscribe((pmDetails1: IEmployee[]) => {
this.pmDetails1 = pmDetails1;
console.log(this.pmDetails1);
});
}
onItemChange(value) {
if (value === '1' ) {
this.check = true;
} else {
this.check = false;
}
}
}
<div>
<table class="table table-light" style="border: 1px solid">
<thead style="background-color: aqua">
<tr>
<th>Select</th>
<th>Name</th>
<th>Role</th>
</tr>
</thead>
<tbody>
<tr
*ngFor="let p of pmDetails1"
>
<td>
<input
type="checkbox"
value="{{ p.id }}"
[checked]="check"
/>
</td>
<td>{{p.name}}</td>
<td>{{p.role}}</td>
</tr>
</tbody>
</table>
</div>
这是控制台上的输出
请帮我解决这个问题。
【问题讨论】:
标签: html asp.net angular typescript api