Wednesday, 21 December 2022

Facing issues while using angular material Datepicker

I'm trying to use basic date picker from angular material website.

<span class="calendar">
            <mat-form-field appearance="outline">
                <mat-label>Date</mat-label>
                <input                
                 matInput 
                 [matDatepicker]="picker">
                <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
                <mat-datepicker #picker></mat-datepicker>
              </mat-form-field>
</span>  

But i get the below error when I click on datepicker

core.js:6185 ERROR TypeError: format.replace is not a function
    at expandFormat (moment.js:537)
    at formatMoment (moment.js:521)
    at Moment.format (moment.js:3975)
    at MomentDateAdapter.format (material-moment-adapter.js:126)
    at MatCalendarHeader.get periodButtonText [as periodButtonText] (datepicker.js:2094)
    at MatCalendarHeader_Template (datepicker.js:2233)
    at executeTemplate (core.js:11949)
    at refreshView (core.js:11796)
    at refreshComponent (core.js:13229)
    at refreshChildComponents (core.js:11527)

But when try the same code in stack blitz it works. Also I'm importing import and exporting { MatDatepickerModule } from '@angular/material/datepicker'; in module. It does not work.

Can you guys please advise



from Facing issues while using angular material Datepicker

No comments:

Post a Comment