ng add @angular/material
自定义预构建主题
? Choose a prebuilt theme name, or "custom" for a custom theme: Custom ? Set up global Angular Material typography styles? Yes ? Set up browser animations for Angular Material? Yes
创建mat.module
ng g module mat
写个例子
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MatButtonModule } from '@angular/material/button';
@NgModule({
declarations: [],
imports: [
CommonModule,
MatButtonModule
],
exports:[
MatButtonModule
]
})
export class MatModule { }
然后只需要在用到这个组件的module导入
import { MatModule } from 'src/app/mat/mat.module';
imports: [
MatModule,
],
即可使用,如
<button mat-button>按钮</button>