Currently, I am dealing with football data retrieved from an API.
https://i.sstatic.net/MRSsH.jpg
When I make a request to this API endpoint, all the available lists are displayed. My goal is to organize the list based on the game status, such as Finished, Postponed, and Timed.
I attempted to achieve this using the following code:
<div *ngFor="let fixture of fixtures">
<div *ngIf="fixture.status !== 'FINISHED'">
<p>{{fixture.date}}</p>
</div>
</div>
Although it successfully filters out the items from view, the complete filtration isn't achieved. Due to the extensive nature of the list, I only want to display the initial 20 items. Here's what I tried:
<div *ngFor="let fixture of fixtures | slice:0:20">
<div *ngIf="fixture.status !== 'FINISHED'">
<p>{{fixture.date}}</p>
</div>
</div>
The intention was to only show the first 20 filtered items from the list, but unfortunately, it did not work as expected. This is because the original unfiltered list is still present.
It seems my current method of filtering is inefficient. The filtering only applies to the presentation in the view, not to the actual list sourced from the API. Therefore, attempts to slice the list do not yield the desired outcome.
If anyone has suggestions on how I can overcome this issue, your assistance would be greatly appreciated. Thank you in advance.