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

690
Views
¿Cómo obtener registros únicos de bucle * ngFor?

Cómo obtener registros únicos de esta matriz. Necesito obtener {{ subitem.author }} de esta matriz de elementos.

 <div *ngFor="let item of items"> <ion-list *ngFor="let subitem of item.items" (click)="authorquotes(subitem.author);"> <ion-item > {{ subitem.author }} </ion-item> </ion-list> </div>

En una matriz que tiene varios registros. De esa matriz, necesito filtrar autores únicos.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Debe crear una tubería que filtre la matriz con elementos únicos:

 @Pipe({ name: 'filterUnique', pure: false }) export class FilterPipe implements PipeTransform { transform(value: any, args?: any): any { // Remove the duplicate elements let uniqueArray = value.filter(function (el, index, array) { return array.indexOf (el) == index; }); return uniqueArray; } }

Entonces puedes aplicar tu tubería:

 <div *ngFor="let item of items | filterUnique"> <ion-list *ngFor="let subitem of item.items" (click)="authorquotes(subitem.author);"> <ion-item > {{ subitem.author }} </ion-item> </ion-list> </div>

Demostración de trabajo: https://plnkr.co/edit/yxvoKVD3Nvgz0T3AB7w3?p=preview

about 4 years ago · Santiago Trujillo 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!