In my Angular project, I'm trying to use *ngFor to display a calendar.
I have my months and the number of days in each, in an array of objects:
public months: Array<Object> = [
{ month: "January", days: 31 },
{ month: "February", days: 28 },
{ month: "March", days: 31 },
{ month: "April", days: 30 },
{ month: "May", days: 31 },
{ month: "June", days: 30 },
{ month: "July", days: 31 },
{ month: "August", days: 31 },
{ month: "September", days: 30 },
{ month: "October", days: 31 },
{ month: "November", days: 30 },
{ month: "December", days: 31 },
];
and then I'm trying to display them using *ngFor. The months display correctly, but I can't quite figure out how to display each of the days correctly. Here's what I have for my html:
<div class="year" style="width: 100%; margin-top: 10px;">
<h1 style="text-align: center; font-weight: 500;">2019 Vacation Calendar</h1>
<div class="months" *ngFor="let month of months">
<div class="month">
<ul>
<li>
{{month.month}}<br>
<span style="font-size:18px">{{currentYear}}</span>
</li>
</ul>
</div>
<ul class="weekdays">
<li>Su</li>
<li>Mo</li>
<li>Tu</li>
<li>We</li>
<li>Th</li>
<li>Fr</li>
<li>Sa</li>
</ul>
<ul class="days">
<li *ngFor="let day of month.days; let i=index">{{i}}</li>
</ul>
</div>
</div>
Right now, I just get an error saying that it couldn't find a "differ supporting object '31' of type 'number'." I'm pretty sure this is because I didn't do something right to allow my ngFor to count from 1 to 31 or however many days there are in each month, but I don't know how to go about doing that. Any help is greatly appreciated, thanks!