Open bzroom opened 1 year ago
I was able to workaround my issue (so far, so good), by following the directions here https://github.com/h2qutc/angular-material-components/issues/182 and using "useClass" to instantiate a unique format provider per component instance. Then in that component, I can dynamically set the value of the provider for that component to have different formats per component which avoids the original issue:
"@angular-material-components/datetime-picker": "^8.0.0", "@angular/core": "^15.2.9",
I'm trying to make a "date only" picker input on my form. I set hideTime="true" and it hides it from the picker, but the time still shows in the value because it's still in in the custom formats used by the other pickers on the form.
The root issue is probably that the date/time format is global rather than an input to the control.
hideTime should hide the time from the format, and/or format should be passed in as input to each control.
My formats: export const INTL_DATE_INPUT_FORMAT = { year: 'numeric', month: 'numeric', day: 'numeric', hourCycle: 'h11', hour: 'numeric', minute: '2-digit', };
// this one should be used for hideTime=true controls. (no time in format) export const INTL_JUST_DAY_INPUT_FORMAT = { year: 'numeric', month: 'numeric', day: 'numeric' };
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = { parse: { dateInput: INTL_DATE_INPUT_FORMAT, }, display: { dateInput: INTL_DATE_INPUT_FORMAT, monthYearLabel: { year: 'numeric', month: 'short' }, dateA11yLabel: { year: 'numeric', month: 'long', day: 'numeric' }, monthYearA11yLabel: { year: 'numeric', month: 'long' }, }, };