'mat-datepicker change date format not working

I am using the providers in my module to change the format of the datepicker in FiltriRecuperoComponent see code below

export const MY_FORMATS = {
  parse: {
    dateInput: 'MM/YYYY',
  },
  display: {
    dateInput: 'MM/YYYY',
    monthYearLabel: 'MMM YYYY',
    dateA11yLabel: 'LL',
    monthYearA11yLabel: 'MMMM YYYY',
  },
};

@NgModule({
  declarations: [
    RecuperoComponent,
    RecuperoScartiComponent,
    RecuperoStatoComponent,
    FiltriRecuperoComponent
  ],
  imports: [
    CommonModule,
    SharedModule,
    RecuperoRoutingModule
  ],
  providers: [
    {provide: MAT_DATE_FORMATS, useValue: MY_FORMATS}
  ]
})
export class RecuperoModule { }

this approach is not working. I tried to use the same providers in FiltriRecuperoComponent but it doesn't work.

What am I missing?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source