javascript - How to disable specific dates in angular material datepicker -


how can disable specific dates based on current date, let's today 8/1/16, want disable 4 days (4 it's example number) after current date weekends days doesn't count,

example if today 8/1/16 want disable 8/2/16 , 8/3/16, 8/4/16 , 8/5/16, , dates available ones after 8/8/16.

at moment know how disable weekend days in calendar filter

$scope.disableselecteddays = function () {                  //i create new moment since going need current date                 var momentjs = new moment();                  if (momentjs <= moment().add(4, 'days')) {                     return false;                 } else {                     //just disable weekends                     var day = date.getday();                     return day === 1 || day === 2 || day === 3 || day === 4 || day === 5;                 }             } 

this 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> 

this versions i'm using angular-maeria: v1.1.0-rc.5 datepicker: datepicker angular material v1.1.0-rc4-master-88f2e3f

edit 1

i edited code answer days in datepicker disabled can't select anything, i'm doing wrong?

i added libaries moment libraries

moment.js version : 2.14.1 angular-moment https://github.com/urish/angular-moment

for scenario, can try using moment.js

to disable number of days after selected date, can (hopefully should work, have not tested, there might typo's)

//date date wanted check

//numberofdays 4 per example

$scope.disableselecteddays = function (date ) {     if(date <= moment().add(4, 'days')) {         return false;     }     else {     //just disable weekends             var day = date.getday();             return day === 1 || day === 2 || day ===3 || day === 4 || day === 5;          }   } 

Comments