在 Angular 9.1.1 中找不到 MatNativeDateModule、MatMomentDateModule

lil*_*lva 17 angular-material

旧的角度/材料具有这两个模块。但是 angular/material 9.1.1 版本没有这两个模块。我得到以下错误。任何人都知道如何导入这两个模块

Uncaught (in promise): Error: MatDatepicker: No provider found for DateAdapter. You must import one of the following modules at your application root: MatNativeDateModule, MatMomentDateModule, or provide a custom implementation.
Error: MatDatepicker: No provider found for DateAdapter. You must import one of the following modules at your application root: MatNativeDateModule, MatMomentDateModule, or provide a custom implementation.
Run Code Online (Sandbox Code Playgroud)

lil*_*lva 39

角 8,9

import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatNativeDateModule } from '@angular/material/core';
Run Code Online (Sandbox Code Playgroud)

Angular 7 及以下

import { MatDatepickerModule, MatNativeDateModule } from '@angular/material';
Run Code Online (Sandbox Code Playgroud)

您需要在导入下导入 MatDatepickerModule 和 MatNativeDateModule 并在提供者下添加 MatDatepickerModule

imports: [
    MatDatepickerModule,
    MatNativeDateModule 
  ],
  providers: [  
    MatDatepickerModule,
    MatNativeDateModule  
  ],
Run Code Online (Sandbox Code Playgroud)

  • 您确定它必须包含在“providers”中吗? (2认同)