How to get all dates and days of a week in angularjs
<script>
function startAndEndOfWeek(date) {
date = "2019-02-26 00:00:00"; -- passing any date here
var now = date ? new Date(date) : new Date();
now.setHours(0, 0, 0, 0);
var monday = new Date(now);
monday.setDate(monday.getDate() - monday.getDay() + 1);
var sunday = new Date(now);
sunday.setDate(sunday.getDate() - sunday.getDay() + 7);
return [monday, sunday];
}
//alert(startAndEndOfWeek(new Date(2019, 03, 28)).join('\n'));
alert(startAndEndOfWeek().join('\n'));
</script>
Result: Mon Feb 25 2019 00:00:00 Sun Mar 03 2019 00:00:00
But I want all dates and days of that week like Mon Feb 25 Tue Feb 26 .. ..
so that i can bind it to the repeater below which will display dates and days in a table.
<body>
<div ng-app>
<div ng-controller="TodoCtrl">
<!--<div ng-repeat="day in weekDays"> {{day}} </div>-->
<table ng-repeat="day in weekDays">
<tr>
<td>
<label for="lblDay">Date - Day: </label>{{day}}
</td>
</tr>
</table>
</div>
</div>
</body>