我正在try 显示注册总数为item.male_students
和item.female_students
UPDATE
移除ngFor现在它可以按预期工作.
这是我的组件.html
<thead class="thead-zircon">
<tr>
<th>
Total Enrollment Quick Count
</th>
</tr>
</thead>
<tbody class="list">
<tr>
<td>
{{ maleCount + femaleCount }}
</td>
</tr>
</tbody>
UPDATED
这是我的配料.
data: [];
constructor(private apiService: ApiService) {
super();
}
ngOnInit(): void {
this.getEnrollMentCountBySex();
}
getEnrollMentCountBySex() {
this.apiService.getAll('enrollments', "/count-student-enrollment-by-sex-and-academic-level")
.subscribe(data => {
this.data = data;
this.maleCount = data.reduce(((acc, item) => acc + item.male_students), 0);
this.femaleCount = data.reduce(((acc, item) => acc + item.female_students), 0);
});
}
我有异议了.以下是来自API端点的和图像
UPDATE
但我得到了所有的索引.我只想在表中显示男女学生的总数