skip to Main Content

I have a problem with vscode, I’m getting an error:

'fa-icon' is not a known element:
1. If 'fa-icon' is an Angular component, then verify that it is part of this module.
2. If 'fa-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.ng

but I’ve already imported it in the module "app.module" and this component (called "base") is a part of the root module.

this problem is only in vscode and the application is running without any errors.

The Error

the code:

base.component.ts:

import { Component } from '@angular/core';
import { faFacebook, faInstagram, faTelegram } from '@fortawesome/free-brands-svg-icons';

@Component({
  selector: 'app-base',
  templateUrl: './base.component.html',
  styleUrls: ['./base.component.scss']
})
export class BaseComponent {

  facebook = faFacebook;
  instagram = faInstagram;
  telegram = faTelegram;

}

base.component.html:

<nav class="navbar navbar-dark bg-dark">
  <div class="container">
    <a class="navbar-brand">
      Quiz App
    </a>
    <div class="text-light float-end fs-5">
      <a href="#"><fa-icon class="text-light p-1" [icon]="facebook"></fa-icon></a>
      <a href="#"><fa-icon class="text-light p-1" [icon]="instagram"></fa-icon></a>
      <a href="#"><fa-icon class="text-light p-1" [icon]="telegram"></fa-icon></a>
    </div>
  </div>
</nav>
<div class="container">
  <router-outlet></router-outlet>
</div>

app.module.ts:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { BaseComponent } from './base/base.component';
import { EffectsModule } from '@ngrx/effects';
import { StoreModule } from '@ngrx/store';
import { HomeComponent } from './views/home/home.component';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';

@NgModule({
  declarations: [
    AppComponent,
    BaseComponent,
    HomeComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    StoreModule.forRoot({}),
    EffectsModule.forRoot([]),
    FontAwesomeModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

2

Answers


  1. What about adding this?

    import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
    Login or Signup to reply.
  2. After restarting VS code, those errors are gone.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search