Something strange happened to my DatePicker today. All of a sudden, when I try to open it, the entire DatePicker appears white and I'm getting this error:
> ERROR Error: Uncaught (in promise): TypeError: format.replace is not a function
TypeError: format.replace is not a function
at expandFormat (moment.js:543:29)
at formatMoment (moment.js:527:18)
at Moment.format (moment.js:3994:22)
at MomentDateAdapter.format (material-moment-adapter.mjs:126:21)
at MatDatepickerInput._formatValue (datepicker.mjs:2907:47)
at MatDatepickerInput._assignValueProgrammatically (datepicker.mjs:2938:14)
at MatDatepickerInput.writeValue (datepicker.mjs:2846:14)
at onChange (forms.mjs:3160:27)
at forms.mjs:3646:50
at Array.forEach (<anonymous>)
at resolvePromise (zone.js:1211:31)
at zone.js:1282:17
at _ZoneDelegate.invokeTask (zone.js:406:31)
at Object.onInvokeTask (core.mjs:26218:33)
at _ZoneDelegate.invokeTask (zone.js:405:60)
at Zone.runTask (zone.js:178:47)
at drainMicroTaskQueue (zone.js:585:35)
I've checked my code but I can't seem to find format.replace
anywhere in it. The console also indicates that the issue isn't coming from my code. I'm puzzled as to why this error has suddenly appeared.
Here's the HTML code for my DatePicker:
<input mat-input [matDatepicker]="basicDatepicker" id="invisibleDate" readonly="readonly" [min]="minDate" [max]="maxDate" [(ngModel)]="currentDate">
<h4 id="datePicker">{{ currentDate | customDate }}</h4>
<mat-datepicker-toggle [for]="basicDatepicker"></mat-datepicker-toggle>
<mat-datepicker #basicDatepicker id="datePickerIcon"></mat-datepicker>