I am trying to make an array with selected dates. I was able to so for the start/end date. Now, I am trying to do it for the inside dates (dates between the start/end date). To do so, I am first building this function:
getDates(start: NgbDate, end: NgbDate) {
var inside = [];
var currentDate = start;
while (currentDate <=end) {
inside.push(currentDate);
currentDate = this.calendar.getNext(currentDate,'d',1);
}
return inside;
}
Then, when I am trying to use it:
this.insideDates = this.getDates(this.startDate, this.endDate);
I am getting this error for memory consumption:
P.S: 1- startDate, & endDate type is NgbDate
2-I am using Angular 7/typescript file.
Thanks in advance.
Update:
If I use below function:
getDates2 = function(start, end) {
var insideDates = [],
currentDate = start,
addDays = function(days) {
var date = new Date(this.valueOf());
date.setDate(date.getDate() + days);
return date;
};
while (currentDate <= end) {
insideDates.push(currentDate);
currentDate = addDays.call(currentDate, 1);
}
return insideDates;
};
and use it as below:
this.insideDates = this.getDates2(this.startDate, this.endDate);
I am getting only the first date (i.e., this.startDate)