0

I'm trying to use angular material in my project. I have done below required settings.

  1. Installation: npm i -S @angular/material @angular/cdk @angular/animations
  2. Importing in app.module.ts: import {MatCheckboxModule} from '@angular/material/checkbox'; and imports: [ BrowserModule, AppRoutingModule, FontAwesomeModule, MatCheckboxModule ],
  3. In app.component.ts: checked = false; labelPosition: 'before' | 'after' = 'after';
  4. And finally app.component.html:

enter image description here

Below is the error:

Error: src/app/app.component.html:104:1 - error NG8001: 'mat-card' is not a known element:

Can someone please help me on this.


NOTE: I'm using bootstrap too in the same project, hope that dosen't impact this.

3 Answers 3

2

you have to include import {MatCardModule} from '@angular/material/card'; for more info https://material.angular.io/components/card/api

Sign up to request clarification or add additional context in comments.

Comments

1

You have configuration issue :

you need to add those in module.ts file and add it in imports ,something like this:

        import { MatCardModule} from '@angular/material';
        
        @NgModule({
  imports:      [ BrowserModule, FormsModule, BrowserAnimationsModule, MatCardModule  ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

Comments

0

So there are few changes I needed to make, thanks to the answers I got.

app.module.ts

...
import { FormsModule } from '@angular/forms';

//angular material
import {MatCardModule} from '@angular/material/card';
import {MatRadioModule} from '@angular/material/radio';

@NgModule({
  imports: [
BrowserModule,
FormsModule,
MatCardModule,
MatRadioModule
  ], . . .

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.