https://jsfiddle.net/x991kcus/
I'm able to generate dates array given a start date and end date as params, but what I want is actually array of object like this
[{date:"2017-4-01"},{{date:"2017-4-02"}}]
Below code gave me array.
function generateDates(startDate, stopDate) {
var dateArray = [];
var currentDate = moment(startDate);
var stopDate = moment(stopDate);
while (currentDate <= stopDate) {
dateArray.push(moment(currentDate).format('YYYY-MM-DD'))
currentDate = moment(currentDate).add(1, 'days');
}
return dateArray;
}
pushing to the array, create an objectoand assign the date too.date. Then push theoto the array.date.isAfter(date2)instead of<=