Counter in second *ngFor

#1

Hi,

<ion-col col-1 *ngFor="let day of wvdaysInThisWeek">
    {{day.DayNr}}
  <span *ngFor="let event of appEvents | async index as i">
    <span *ngIf="(event.day) == (day.DayNr)"> <br>i: {{i+1}} e: {{event.name}}</span>
  </span>
</ion-col>

Is there any posibilities for show number of events per day instead of names for the events?

Now I have:
3c5a2052b1a21d3e1ea8273c45fce3d2

And I want to have something like this:
7488177ed8d96b5f23a403b75bdb3a26

#2

I would shift all the work to the controller. When appEvents is populated, build up a map of days to count of events. That way the template can be as simple as {{eventCount[day]}}.

1 Like
#3

Great, thank you:) I learned some about mapping and now works fine.