I would like to use Angular Materials slider to choose date.
I have created this codepen to demonstrate a simple slider that chooses a number. https://codepen.io/helpme/pen/meLWBL?#
.sliderdemoBasicUsage input[type="number"] {
text-align: center; }
However, I would like to modify this code such that the slider choose a date instead of a number. The date is actually a month date and as the slider slides, the date changes by the month. The date is of the format 2004-06-01
, 2004-07-01
, 2004-08-01
.
Can the Angular Materials slider be modified to support date that follows my format? How can the codepen be modified to support it?
Here you have my solution to what you are looking for: https://codepen.io/anon/pen/avGJGp?editors=101
HTML
important part is here:I set
min="1"
andmax="12"
as the possible month range numbers that can be chosen, and the slider value is bound to$scope.month
throughng-model="month"
.Changed the input type to
type="text"
and I set it's value to the string"2008-{{month}}-1"
, where the year and day number always stay the same, but the month changes when you use the slider as it was bound to$scope.month
.The
Angular
controller would just stay this way: