[Fixed] angular calendar / days. So basically I want to know if there is any built in method to generate the whole week?


is there any way to create calendar days in angular?
for example, I can render what day is today but I do not know how to generate the whole week.

enter image description here

so this is what I have but I need for the whole week

here is the code for his picture

    <div class="date">
        <span class="weekDay">{{today | date:'EEE' }}</span>
        <span class="dayNum">{{today | date:'d'}}</span>
        <span class="month">{{today | date:'MMM' }}</span>


you has "getDay" to know the week day of a date (see that 0 is Sunday). Some like

  date=new Date()
  monday=new Date(this.date.getTime()-this.incr*24*60*60*1000)
  week=[0,1,2,3,4,5,6].map(x=>new Date(this.monday.getTime()+x*24*60*60*1000))

give you a array week with the dates from Monday

If your week starts in Sunday you need change the incr.

NOTE: you can also check this SO to create a full calendar

Leave a Reply

(*) Required, Your email will not be published