Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

230
Visualizações
How to get a font awesome icon name when using click event on it?

So, if I do this in my HTML component:

<fa-icon [icon]="faSort" (click)="sort($event)"></fa-icon>

How will I get it's name in my ts component?

sort(event: Event) {???}

I tried doing it like this:

sort(event: Event) {

console.log(event['target']['ownerSVGElement']['classList'][1])

}

But the method above is very inconsistent. Is there a better way of doing this?

Font Awesome Package Link: https://www.npmjs.com/package/@fortawesome/angular-fontawesome

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Assuming you don't really care about anything else that the event value may contain within it.

sort(event : any) {
   console.log("Icon Name: ", event.iconName);
}

<fa-icon [icon]="faSort" (click)="sort({ iconName: 'faSort'})"></fa-icon>

Assuming you still want to capture the actual event itself:

<fa-icon [icon]="faSort" (click)="sort({event: $event, iconName: 'faIcon'})"></fa-icon>

The reason this works is that we allow our sort to accept a type of any, and we are creating a brand new object using the curly braces.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda