angular / angular/components

Change datepicker parse and display format at runtime

Offen
#8,355 23 Kommentare 50 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: material/datepicker feature P3
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

#### Bug, feature request, or proposal:
Currently the parse and display format of a datepicker can only be set before runtime by providing them with ```provide: MAT_DATE_FORMATS, useValue: MY_DATE_FORMATS```.
As shown in the example: https://material.angular.io/components/datepicker/examples

#### What is the expected behavior?
The parse and display format of the datepicker should also be able to be changed at runtime, the same way it's possible to change the locale at runtime with ```.setLocale()```.
Maybe add ```.setDateFormat(MY_DATE_FORMAT_GENERATED_AT_RUNTIME)```, as sometimes the date format is only available after a HTTP request to the server.

#### What is the current behavior?
Date format is set in provider and cannot be changed at runtime.

#### What is the use-case or motivation for changing an existing behavior?
It should be possible to change the date format at runtime, to be able to react to date-formats, set by the backend. The user can set a preferred date format in the application and the application has to retrieve it from the server and adjust the datepicker accordingly. This is currently not possible.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit den Angular Material datepicker-Beispielen und dem im Issue gezeigten MAT_DATE_FORMATS-Provider und verfolge anschließend, wie setLocale() das Verhalten des datepicker ändert. Definiere und überprüfe einen Laufzeitmechanismus zum Aktualisieren der Parse- und Anzeigeformate nach einer Serverantwort, einschließlich des erwarteten Verhaltens bei einer Formatänderung.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.