Is it possible to prevent specific dates from being selected based on the current date? For example, if today is 8/1/16, I would like to disable the next 4 days (any number of days could be chosen), excluding weekends.
So, if today is 8/1/16, I would want to prevent selection of 8/2/16, 8/3/16, 8/4/16, and 8/5/16. Only dates after 8/8/16 would be available for selection.
Currently, I only know how to disable all weekend days in the calendar using the following filter:
$scope.disableSelectedDays = function () {
//Creating a new moment instance to always have the current date
var momentJS = new moment();
if (momentJS <= moment().add(4, 'days')) {
return false;
} else {
//Disabling only weekends
var day = date.getDay();
return day === 1 || day === 2 || day === 3 || day === 4 || day === 5;
}
}
This is my html:
<div class="form-group">
<label>Delivery date:</label>
<md-datepicker ng-model="myDate" md-placeholder="Enter date"
md-date-filter="disableSelectedDays">
</md-datepicker>
</div>
These are the versions I am currently using:
angular-maeria: v1.1.0-rc.5 datepicker: datepicker from angular material v1.1.0-rc4-master-88f2e3f
EDIT 1
I tried implementing the changes you suggested, but now all dates in the datepicker are disabled and I can't select anything. What am I doing wrong?
Additionally, I have added the following libraries:
moment.js version: 2.14.1 angular-moment https://github.com/urish/angular-moment