{"record":{"id":"efac8086e8430e30","repo":"angular/components","slug":"matdatepicker-no-provider-found-for-dateadapter-efac80","errorCode":null,"errorMessage":"MatDatepicker: No provider found for DateAdapter. 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 DateAdapter\\. 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":158,"sourceCode":"  /** Grid of calendar cells representing the months of the year. */\n  _months = signal<MatCalendarCell[][]>([]);\n\n  /** 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  }","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/material/datepicker/year-view.ts#L140-L176","documentation":"MatYearView renders a 12-month grid and injects DateAdapter plus MAT_DATE_FORMATS. The dev-mode guard throws when no DateAdapter provider exists in the injector. It's the year-level counterpart of the month/multi-year view checks.","triggerScenarios":"Rendering the year view (via mat-calendar in year mode or mat-year-picker) when the injector lacks a DateAdapter provider.","commonSituations":"Standalone apps missing provideNativeDateAdapter; test benches constructing MatYearView without providers; provider removal during refactors to standalone components.","solutions":["Add provideNativeDateAdapter() to the application's root providers","Use the library-specific provider (provideDateFnsAdapter/provideLuxonDateAdapter/provideMomentDateAdapter) as appropriate","In tests add the provider to TestBed.configureTestingModule"],"exampleFix":"// before\nTestBed.configureTestingModule({imports: [MatDatepickerModule]})\n// after\nTestBed.configureTestingModule({imports: [MatDatepickerModule], providers: [provideNativeDateAdapter()]})","handlingStrategy":"validation","validationCode":"const adapter = inject(DateAdapter, {optional: true});\nif (!adapter) throw new Error('Add provideNativeDateAdapter() to providers');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provide the date adapter at root level for all datepicker views","Add TestBed providers in every test importing datepicker modules","Standardize on one provide*Adapter() function across the app"],"tags":["angular","material","datepicker","dependency-injection","configuration"],"backgroundTag":"missing-dateadapter-provider","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}