Open shivamkatyan opened 8 months ago
For now i have a dirty fix to resolve the issue on my side. I am using opened event of datetime picker and manually setting the date if no value exists in formcontrol's value.
` <ngx-mat-datetime-picker
[showSpinners]="showSpinners"
[showSeconds]="showSeconds"
[stepHour]="stepHour"
[stepMinute]="stepMinute"
[stepSecond]="stepSecond"
[touchUi]="touchUi"
[color]="color"
[enableMeridian]="enableMeridian"
[disableMinute]="disableMinute"
[hideTime]="hideTime",
(opened)="setOpenedDate(picker)"
>`
and
public setOpenedDate(datePicker: any): void { const dateCtrl: FormControl = this.dateControl; dateCtrl.setValue(dateCtrl.value || new Date()); datePicker._selected = dateCtrl.value; datePicker.startAt = datePicker._selected; }
This is just a dirty workaround, if anyone have a better workaround or a fix, please update
I can confirm the defaultTime property seems to be broken, I think it has something to do with commit #1d7387a https://github.com/h2qutc/angular-material-components/commit/1d7387ac2b9ab0fb345ef270d6cca5d25d07536a
@h2qutc could you please look in to this/give feedback?
@h2qutc Any update on this issue?
@h2qutc Could we have a fix for this issue ?
For now i have a dirty fix to resolve the issue on my side. I am usign opened event of datetime picker and manually setting the date if no value exists in formcontrol's value.
<ngx-mat-datetime-picker #picker [showSpinners]="showSpinners" [showSeconds]="showSeconds" [stepHour]="stepHour" [stepMinute]="stepMinute" [stepSecond]="stepSecond" [touchUi]="touchUi" [color]="color" [enableMeridian]="enableMeridian" [disableMinute]="disableMinute" [hideTime]="hideTime", (opened)="setOpenedDate(picker)" >
and
public setOpenedDate(datePicker: any): void { const dateCtrl: FormControl = this.dateControl; dateCtrl.setValue(dateCtrl.value || new Date()); datePicker._selected = dateCtrl.value; datePicker.startAt = datePicker._selected; }
This is just a dirty workaround, if anyone have a better workaround or a fix, please update
@shivamkatyan I tried your workaround. But there is still no selected date and hour in the UI (startAt is correctly set in the model). Is there any other modifications you made to apply the start date to the view ?
For now i have a dirty fix to resolve the issue on my side. I am usign opened event of datetime picker and manually setting the date if no value exists in formcontrol's value.
<ngx-mat-datetime-picker #picker [showSpinners]="showSpinners" [showSeconds]="showSeconds" [stepHour]="stepHour" [stepMinute]="stepMinute" [stepSecond]="stepSecond" [touchUi]="touchUi" [color]="color" [enableMeridian]="enableMeridian" [disableMinute]="disableMinute" [hideTime]="hideTime", (opened)="setOpenedDate(picker)" >
andpublic setOpenedDate(datePicker: any): void { const dateCtrl: FormControl = this.dateControl; dateCtrl.setValue(dateCtrl.value || new Date()); datePicker._selected = dateCtrl.value; datePicker.startAt = datePicker._selected; }
This is just a dirty workaround, if anyone have a better workaround or a fix, please update@shivamkatyan I tried your workaround. But there is still no selected date and hour in the UI (startAt is correctly set in the model). Is there any other modifications you made to apply the start date to the view ?
I've opened a MR to solve this. Hope it'll be merged soon 😄
@samuele-ruffino96 Is your fix working? Does that solve the issue of not showing empty time fields in the UI? Because I see the MR you've created is closed without merging.
@samuele-ruffino96 Is your fix working? Does that solve the issue of not showing empty time fields in the UI? Because I see the MR you've created is closed without merging.
Yes, it does. I closed it because this repo was probably no longer be maintained by @h2qutc. A reworking is currently in progress (link below). If it's gonna succeed, i'll reopen a PR there if the issue still persist.
@samuele-ruffino96 Any update on your PR in the new reworked repository (link you provided in your previous message)? There seems to be no ETA for completion of reworking. The workaround proposed before isn't working for me.
For now i have a dirty fix to resolve the issue on my side. I am usign opened event of datetime picker and manually setting the date if no value exists in formcontrol's value.
<ngx-mat-datetime-picker #picker [showSpinners]="showSpinners" [showSeconds]="showSeconds" [stepHour]="stepHour" [stepMinute]="stepMinute" [stepSecond]="stepSecond" [touchUi]="touchUi" [color]="color" [enableMeridian]="enableMeridian" [disableMinute]="disableMinute" [hideTime]="hideTime", (opened)="setOpenedDate(picker)" >
andpublic setOpenedDate(datePicker: any): void { const dateCtrl: FormControl = this.dateControl; dateCtrl.setValue(dateCtrl.value || new Date()); datePicker._selected = dateCtrl.value; datePicker.startAt = datePicker._selected; }
This is just a dirty workaround, if anyone have a better workaround or a fix, please update@shivamkatyan I tried your workaround. But there is still no selected date and hour in the UI (startAt is correctly set in the model). Is there any other modifications you made to apply the start date to the view ?
@lilas78 I'm facing the same issue. Have you found a solution to resolve it?
I recently migrated to v16.x from v9.x during my migration to angular v16.2.x IN previous version if there was no default value, then datetime picker would default to current date and time, but now it is just blank.
I have tried seeting up a startDate and defaultTime but they do not work as well.
if there is value in form then it works correctly,
if there is no date time set then
stackblitz: https://stackblitz.com/github/shivamkatyan/angular-material-components