I have created a new project, and I am trying to add angular-material
.
I have created material.module.ts
in my app
folder:
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:
<mat-icon>home</mat-icon>
Best way
for a quick good fix
import {MatToolbarModule} from '@angular/material/toolbar';
in your app.module.ts
then declare MatToolbarModule in your declarations[].
Works fine for me here: https://stackblitz.com/edit/angular-w9ckf8
Look over the link and see if there's anything you are missing.