File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -340,6 +340,27 @@ In this example, the drop-down functionality is controlled by Twitter Bootstrap.
340340The <code >dropdownSelector</code > tells the datetimepicker which element is bound to the Twitter Bootstrap drop-down so
341341the drop-down is toggled closed after the user selects a date/time.
342342
343+ ### Restrict past dates from being selected
344+
345+ ``` html
346+ <datetimepicker data-ng-model =" startDate" data-before-render =" startDateBeforeRender($dates)" >
347+ </datetimepicker >
348+ ```
349+
350+ We filter dates that are past today and set selectable to false
351+
352+ ``` javascript
353+ $scope .startDateBeforeRender = function ($dates ) {
354+ const todaySinceMidnight = new Date ();
355+ todaySinceMidnight .setUTCHours (0 ,0 ,0 ,0 );
356+ $dates .filter (function (date ) {
357+ return date .utcDateValue < todaySinceMidnight .getTime ();
358+ }).forEach (function (date ) {
359+ date .selectable = false ;
360+ });
361+ };
362+ ```
363+
343364### Create a date range picker with validation controls
344365``` html
345366<div class =" dropdown form-group" >
You can’t perform that action at this time.
0 commit comments