Skip to content
This repository has been archived by the owner on Sep 13, 2021. It is now read-only.

Display date range "MM/DD/YYYY - MM/DD/YYYY" in the input as default #16

Closed
Smiter15 opened this issue May 25, 2018 · 2 comments
Closed

Comments

@Smiter15
Copy link

Hi, I really like your range date picker its exactly what I want from angular material ! Thanks for your work. I was just wondering if there is a simple way to set a default date. I can't pass in a variable as a string e.g. '01/01/2018 - 05/25/2018' through [(ngModel)]. It doesn't error but just nothing appears. According to the docs the date picker accepts a JavaScript Date variable. I can pass this in and it appears but it is only of the one date.

I can pass in an object e.g
{
"begin": "2018-01-01T12:00:00.000Z",
"end": "2018-05-25T12:00:00.000Z"
}
and this does appear as my default range ! Alas, when I change the range through the date picker it then doesn't update, even if I reassign the new values through the $event.

Let me know if I'm missing anything.

@SaturnTeam
Copy link
Owner

Datepicker expects that begin and range value will be the date instances. not strings.

@Smiter15
Copy link
Author

Thanks @SaturnTeam ! That worked :)

this.date = {
            'begin': new Date('January 01, 2018'),
            'end': new Date()
        };

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants