the mbsc-datepicker, upon setting a value with ngModel, will sometime emit a new value through ngModelChange.
Under no circumstances should ngModelChange emit in consequence of setting a new value through ngModel. ngModelChange should only emit when user sets a new value through the UI.
This is causing a lot of issues for us, like infinite loops and API spam
For example, when provided [null, null] to a range datepicker, it immediatly outputs null as output. To avoid this, when my start_date and end_date are null, I need to convert to an empty array before sending it to the datePicker.
Also, if the range datePicker is to output something (it should not in this scenario), shouldn’t it be an array of two null values?
Is this normal? For a range datepicker that requires an array of two dates, not being able to handle [null, null] seems like a design flaw or a bug
Hi @Jacques_Hache
Have you considered using
[value]="date"
(onChange)="modelChange($event)"
instead of
[(ngModel)]="date"
(ngModelChange)="modelChange($event)"
The args.value
in the onChange is different. If an array [null, null] is given as value, an empty array is returned.
As for the event emitting, in case of the range picker indeed, both the onChange
and ngModelChange
are triggered when the component is initialized.