Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
¿Cómo obtener un nombre de icono impresionante de fuente cuando se usa el evento de clic en él?

Entonces, si hago esto en mi componente HTML:

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

¿Cómo obtendré su nombre en mi componente ts?

 sort(event: Event) {???}

Intenté hacerlo así:

 sort(event: Event) { console.log(event['target']['ownerSVGElement']['classList'][1]) }

Pero el método anterior es muy inconsistente. ¿Hay una mejor manera de hacer esto?

Enlace del paquete Font Awesome: https://www.npmjs.com/package/@fortawesome/angular-fontawesome

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Suponiendo que realmente no le importe nada más que el valor del evento pueda contener.

 sort(event : any) { console.log("Icon Name: ", event.iconName); } <fa-icon [icon]="faSort" (click)="sort({ iconName: 'faSort'})"></fa-icon>

Suponiendo que aún desea capturar el evento real en sí:

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

La razón por la que esto funciona es que permitimos que nuestro tipo acepte un tipo de cualquiera, y estamos creando un objeto completamente nuevo usando las llaves.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!