1、新建项目,安装npm依赖后,
ng add @angular/material
配置npm和添加一起的命令:
npm i --s @angular/material @angular/cdk @angular/animations
问题1:
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.
原因: MatDatepicker依赖于MatNativeDateModule,这两个模块需要一起引入
解决:
import {MatDatepickerModule} from '@angular/material/datepicker';
import { MatNativeDateModule } from '@angular/material/core';