Im trying to display total counts of enrollment with item.male_students
& item.female_students
UPDATE
remove the ngFor now it works as expected.
here's my component.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
here's my component.ts
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);
});
}
Im getting object. Here's and image from api endpoint
UPDATE
But im getting all the index. I only want the total count of male & female students to be shown in table