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

158
Views
¿Cómo omitir la impresión y no mostrar el elemento si no es cierto? Vainilla JS/TS y angular 9

Tengo el problema de que si mi valor es número me salto esa interacción y no la imprimo

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

0

En ts

 sanitize(val){ return val.split('/').pop().replace(/-/g, " "); } get bookLinks() { return this.book.links .map(item=> ({...item, href:this.sanitize(item.href)})) .filter(item=> !this.isNumeric(item.href)); }

en plantilla

 <button type="button" *ngFor="let singleBook of bookLinks"> <span (click)="showI(book, $event, i)" > {{ singleBook.href }} </span> </button>
about 4 years ago · Juan Pablo Isaza Report

0

Iterar sobre los elementos deseados. Significa que no use book.links en ngFor, sino que use su propia matriz derivada, sin elementos vacíos.

P.ej

 <button *ngFor="let singleBook of validLinks" type="button"> ... </button>

Y use, por ejemplo, getter en el componente

 get validLinks () { return this.book.links.filter(b => !!b.trim()) }
about 4 years ago · Juan Pablo Isaza Report

0

Como no puede usar varias instrucciones de estructura/condicionales en el mismo elemento (ngif + ngfor), puede solucionar el problema usando un contenedor ng-container.

 <ng-container *ngFor="let singleBook of book.links"> <button type="button" *ngIf="selectedAction(singleBook.href)"> <span (click)="showI(book, $event, i)"> {{ selectedAction(singleBook.href) }} </span> </button> </ng-container>
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!