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

159
Views
How to skip print and not show item if not true ? Vanilla JS/TS and angular 9

I have a problem that if my value is number I skip that interaction and don't print it

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

0

In 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));
}

In template

<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

Iterate over desired items. It means do not use book.links in ngFor but use your own derived array, without empty items.

Eg

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

And use eg getter on component

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

0

As you cannot use several structure/conditional instructions on same element (ngif + ngfor), you might fix the issue by using a ng-container wrapper.

<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!