question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

datepicker: startAt and setting value doesn't work correctly

See original GitHub issue

repro (using mmalerba:dp-a11y):

  • predefine value to 2017-05-02 (YYYY-MM-DD), input shows correctly 02/05/2017
  • open datepicker, it opens on a wrong month (second, instead of the fifth)
  • select 6th day of the second month (that was open), input changes to 06/02/2017 (should have been 06/05/2017)
  • close and open input again, selected day is set to second of february, but calendar opens at sixth month

@mmalerba

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
mzernetschcommented, Jun 13, 2017

Found a simple workaround that works for my use-case. I set the startAt property to the date i provide as ngModel. Now (using german locale) the datepicker will open at the correct month.

  <md-input-container>
    <input mdInput [mdDatepicker]="picker" placeholder="Choose a date" [(ngModel)]="date">
      <button mdSuffix [mdDatepickerToggle]="picker"></button>
    </md-input-container>
  <md-datepicker #picker [startAt]="date"></md-datepicker>
1reaction
emreavsarcommented, May 31, 2017

I cannot understand how you guys from material are not providing at least one MomentDateAdapter, so that everyone can use a basic version of i18nalized date-pickers. I know there are ways to implement it, but only supporting MM-DD-YYYY out of the box is not enough.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Material Date-Picker is not working properly
I have used material datepicker in angular 7. Go through this and hope it will resolve your issue.
Read more >
Datepicker selected value - StackBlitz
can be found in the LICENSE file at http:/ /angular.io/license -->.
Read more >
Datepicker | Angular Material - API Manual
The startView property of <mat-datepicker> can be used to set the view that will show up when the calendar first opens. It can...
Read more >
Angular Material Datepicker: Complete Guide
Complete guided tour to the Angular Material Datepicker component, from the most commonly used features to the most advanced ones.
Read more >
Datepicker in Angular using mat-datepicker | Material Design
By default when we open calender pop up it will show the current month calender. Instead of that if we want to set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found