Set minDate/maxDate dynamically on html datepicker
Using moment here for date formation
DEMOReference ----> https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
//Taken current date as min date. and random as max date.
// Default format of date is as "YYYY-MM-DD" so we need to convert using moment
minDate = moment(new Date()).format('YYYY-MM-DD')
maxDate ="2018-09-08"
HTML:
<input class="form-control" type="date" [min]="minDate" [max]="maxDate">
angularjs datepicker to set max date and min date dynamically
It seems that the element's configuration once initialized cannot be changed. Try putting the arrival input in ngIf, so that it is always rendered anew when departure changes.
Angular Material Datepicker min and max not working: Type 'Date' is not assignable to type 'number'
I found the culprit. The problem only occurs, when I import CustomFormsModule from 'ng2-validation' in my module.
As soon as I remove it, the correct min/max directives are used and no more errors are shown.
Related Topics
How to Set Filename for Base64 Rendered Pdf Using Object Tag
How to Remove Specific Text With CSS
Angular Detect When Scroll Reached Certain Point
Removing Margin from Flex Items When They Wrap
Print Page Numbers on Pages When Printing HTML
What to Do Regular Expression Pattern Doesn't Match Anywhere in String
One Flex/Grid Item Sets the Size Limit For Siblings
Html 5: Is It ≪Br≫, ≪Br/≫, or ≪Br /≫
Setting Attribute Disabled on a Span Element Does Not Prevent Click Events
How to Make CSS Grid Items Take Up Remaining Space
How to Make Flex Box Work in Safari
First Name Validation Using HTML 5 Pattern
How to Embed Pdf File With Responsive Width
Css Margin Terror; Margin Adds Space Outside Parent Element
Is There a ≪Meta≫ Tag to Turn Off Caching in All Browsers