angular / angular/components

Change datepicker parse and display format at runtime

Aperta
#8,355 23 commenti 50 reazioni 0 assegnatari Vedi su GitHub
area: material/datepicker feature P3
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

#### 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con gli esempi di datepicker di Angular Material e con il provider MAT_DATE_FORMATS mostrato nell’issue, quindi traccia come setLocale() modifica il comportamento del datepicker. Definisci e verifica un meccanismo runtime per aggiornare i formati di parsing e visualizzazione dopo una risposta del server, incluso il comportamento previsto quando il formato cambia.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
frontend
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.