ngx-daterangepicker-material
ngx-daterangepicker-material copied to clipboard
Single date picker initial value or change it in the component
When using the singleDatePicker option, I can't set the initial value or chage the selected value programatically:
Template:
<input type="text" name="my-date" required readonly ngxDaterangepickerMd [(ngModel)]="myDate" [singleDatePicker]="true" [autoApply]="true" />
Component:
public myDate: Moment;
this.myDate= moment().add(-1, 'months');
As result, always is shown the selected date as the current date and no a month ago as should be.
My workaround was use the model like in the range selection:
public myDate: { startDate: Moment, endDate: Moment }
this.myDate= { startDate: moment().add(-1, 'months'), endDate: moment().add(-1, 'months') }
Hello. I have this problem too and I try to find solutions.
hello @bear-wolf @sebrojas14 , this is abug I need to solve because for single datepicker it should be directly the date.
For now, until I got it solved, the workaround is to initialize with an object like the range did it:
this.myDate= { startDate: moment().add(-1, 'months'), endDate: moment().add(-1, 'months') }
@sebrojas14 thank you for reporting
I have this problem as well. I solved it using @fetrarij May 7 solution above.
Also note that if you do not manually set the start date, not only does it default to 'now', it also defaults to returning local time zone offset when selected. Manually setting start time using a UTC time seems to fix this.
Hello!
if i use this.myDate= { startDate: moment() } it works too
Hello. @fetrarij I have this problem in single Date not set. angular version:- 12.2.0 version:- "ngx-daterangepicker-material": "^5.0.1"
how can i get a space between From date and To date , Please repond