1

a quick query --

Am using angular-material 8.2.3 in my angular 8 app - getting the following error wrt md-icon.

'md-icon' is not a known element: 1. If 'md-icon' is an Angular component, then verify that it is part of this module.

this html --

<div class="image-picker" (click)="fileInput.click()">
   <mat-icon [class.small]="imageUrl">file_upload</mat-icon>
   <canvas width="500" height="380" #canvas hidden="true"></canvas>
   <input #fileInput type="file" hidden="true" (change)="imageDataChanged($event)">
</div>

I have in my app.module.ts file the following line --

import { MatInputModule, MatButtonModule, MatSelectModule, MatIconModule, MatCardModule } from '@angular/material';

and in imports section MatIconModule mentioned clearly.

Any clue what's missing or what may be wrong here?? If you observe in the html I pasted, it is mat-icon. Originally that was md-icon and I changed that to try out. Neither did the trick. I hope I have imported the correct package.

Can you tell me what exactly it is? What did I do incorrect?

My NgModule code --

@NgModule({
  declarations: [
    AppComponent,
    FooterComponent,
    BasicLayoutComponent,
    LoginComponent,
    RegistrationComponent,
    CameraSnapshotComponent,
    ImagePickerComponent,
    BlockUIComponent,
    UpdateImageComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    FormsModule,
    MatInputModule,
    MatButtonModule,
    MatSelectModule,
    MatIconModule,
    MatCardModule
  ],
  exports:
    [
      MatInputModule,
      MatButtonModule,
      MatSelectModule,
      MatIconModule,
      MatCardModule
    ],
  providers: [],
  bootstrap: [AppComponent]
})
Prabir Choudhury
  • 143
  • 1
  • 18
  • 1
    Could you update your question with your `NgModule` code – C.OG Jan 01 '20 at 12:40
  • The posted code doesn't have any `md-icon` element. So either the message is different from what you posted, or the code is different from what you posted, or the error is caused by some other code than the one you posted, which does have an `md-icon` element. – JB Nizet Jan 01 '20 at 12:50
  • hi @C_Ogoo updated, pl take a look, – Prabir Choudhury Jan 01 '20 at 13:02
  • hi @JBNizet I explained that in the 3rd main stanza of my question, – Prabir Choudhury Jan 01 '20 at 13:03
  • So, do you still get that precise and exact message, or not? If you don't, then post the actual message you get. If you still do, then fix the code that still contains an `md-icon` element. – JB Nizet Jan 01 '20 at 13:05
  • @PrabirChoudhury search for all occurences of `md-icon` in your codebase. Also restart your dev server if you havent already – C.OG Jan 01 '20 at 13:05
  • Yes, in both cases the same error message !! @JBNizet Baffling !! Ok, that's a good pointer, I'll do a search if any more occurrences, – Prabir Choudhury Jan 01 '20 at 13:07
  • 2
    Again, that most probably means that some **other** code still using md-icon is causing that error. Find it and fix it. Or that you forgot to save the changes to you file. Or that you're not editing the file you think is used by the CLI. Or that the CLI needs to be restarted. – JB Nizet Jan 01 '20 at 13:09
  • Yes, there was another instance of md-icon in another file. Also, I stopped and restarted CLI angular server. That error is now gone. @JBNizet – Prabir Choudhury Jan 01 '20 at 13:16

0 Answers0