'mat-toolbar' is not a known element - Angular 5

前端 未结 3 688
太阳男子
太阳男子 2021-01-03 21:14

I have created a new project, and I am trying to add angular-material.

I have created material.module.ts in my app folder:

3条回答
  •  独厮守ぢ
    2021-01-03 21:25

    That's because you have to import a module to the module which contains the component declaration, not into the component itself:

    app.module.ts

    import { MaterialModule } from './material.module';
    
    @NgModule({
      imports: [
        // ...
        MaterialModule
      ],
      declarations: [
        MyCoolComponent,
        // ...
      ]
    })
    

    P.S. The correct way to use a material icon is to use the MatIcon component. Example usage:

    home
    

提交回复
热议问题