{"record":{"id":"248a3ab4759f4f02","repo":"angular/components","slug":"matdatepicker-no-provider-found-for-mat-date-form-248a3a","errorCode":null,"errorMessage":"MatDatepicker: No provider found for MAT_DATE_FORMATS. You must add one of the following to your app config: provideNativeDateAdapter, provideDateFnsAdapter, provideLuxonDateAdapter, provideMomentDateAdapter, or provide a custom implementation.","messagePattern":"MatDatepicker: No provider found for MAT_DATE_FORMATS\\. You must add one of the following to your app config: provideNativeDateAdapter, provideDateFnsAdapter, provideLuxonDateAdapter, provideMomentDateAdapter, or provide a custom implementation\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/material/datepicker/year-view.ts","lineNumber":161,"sourceCode":"  /** The label for this year (e.g. \"2017\"). */\n  _yearLabel = signal('');\n\n  /** The month in this year that today falls on. Null if today is in a different year. */\n  _todayMonth = signal<number | null>(null);\n\n  /**\n   * The month in this year that the selected Date falls on.\n   * Null if the selected Date is in a different year.\n   */\n  _selectedMonth = signal<number | null>(null);\n\n  constructor() {\n    if (typeof ngDevMode === 'undefined' || ngDevMode) {\n      if (!this._dateAdapter) {\n        throw createMissingDateImplError('DateAdapter');\n      }\n      if (!this._dateFormats) {\n        throw createMissingDateImplError('MAT_DATE_FORMATS');\n      }\n    }\n\n    this._activeDate = this._dateAdapter.today();\n  }\n\n  ngAfterContentInit() {\n    this._rerenderSubscription = this._dateAdapter.localeChanges\n      .pipe(startWith(null))\n      .subscribe(() => this._init());\n  }\n\n  ngOnDestroy() {\n    this._rerenderSubscription.unsubscribe();\n  }\n\n  /** Handles when a new month is selected. */\n  _monthSelected(event: MatCalendarUserEvent<number>) {","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/material/datepicker/year-view.ts#L143-L179","documentation":"MatYearView also requires MAT_DATE_FORMATS to format month labels. This dev-mode guard throws when the token is unprovided, even if a DateAdapter exists. Provider functions like provideNativeDateAdapter register both tokens, so this usually indicates a hand-rolled provider set.","triggerScenarios":"Rendering the year view with a custom or manual DateAdapter provider but no MAT_DATE_FORMATS provider in the same injector.","commonSituations":"Manual {provide: DateAdapter, useClass: ...} registrations copied from older docs; overriding MAT_DATE_FORMATS with a partial object removing it from providers; environments with isolated providers (route-level components).","solutions":["Add {provide: MAT_DATE_FORMATS, useValue: ...} (or rely on provideNativeDateAdapter which includes formats) to the providers","Replace manual provider tuples with the official provide*Adapter() functions that register both tokens","Audit providers on the injector that hosts the calendar to confirm both tokens are present"],"exampleFix":"// before\nproviders: [{provide: DateAdapter, useClass: NativeDateAdapter}]\n// after\nproviders: [provideNativeDateAdapter()]","handlingStrategy":"validation","validationCode":"const formats = inject(MAT_DATE_FORMATS, {optional: true});\nif (!formats) throw new Error('Add MAT_DATE_FORMATS (e.g. via provideNativeDateAdapter())');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use provideNativeDateAdapter() rather than manual provider tuples","When overriding formats, keep the adapter provider intact","Review route/component-level providers that may shadow root providers"],"tags":["angular","material","datepicker","dependency-injection","configuration"],"backgroundTag":"missing-dateadapter-provider","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}