md-datepicker with min/max date gets error
When I use the md-datepicker with no min/max dates, it works fine.
When I add the min/max dates:
<md-datepicker ng-model="settings.effectiveDate" md-min-date="09/21/2015" md-max-date="09/10/2017"></md-datepicker>
...I get the following error:
TypeError: end.getFullYear is not a function
The error reminded me of the javascript Date object. So I changed the code to:
$scope.minDate = new Date(2015, 8, 21);
$scope.maxDate = new Date(2017, 8, 10);
and
<md-datepicker ng-model="settings.effectiveDate" md-min-date="minDate" md-max-date="maxDate"></md-datepicker>
It Works!
So, it appears that the min/max values MUST be Date objects.
The documentation (https://material.angularjs.org/HEAD/#/api/material.components.datepicker/directive/mdDatepicker) does not say anything about the expression type.
The short term solution is to update the documentation to say the expression must evaluate to a Date object.
The longer term solution is to support either Date objects or string objects (ex: moment.format('MM/DD/YYYY').
The documentation here demonstrates how to use minDate and maxDate.
To view it either open the CodePen or click on <> to View Source and then the JS tab.
Ideally, this kind of question would be first asked on the forums.
For sure you are correct.. I will post additional q's on the forums. Thanks for the link.
For now it's going to continue just being a Date object, which string input possibly coming later as a feature (maybe as a community PR). Need to update the docs.
Not working as expected when on years view. Showing years only starting from 2014 instead of 1995.
ref here: http://codepen.io/pen/rLypoy
Still can't set a maxdate on the years view. Does somebody knows a solution?
@sjoerdvalk1991 Please try Stack Overflow, Gitter, or the AngularJS Material forums.