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

165
Views
How to print the array of elements in Angular 12 and Typescript?

I am not able to display the array of elements values in html page.

I have selected values of json array of object, from this result I removed the duplicate category values, and that values convered to array of string. and I listed that array of element. But I don't know to display the forEach element in a ngFor loop in angular.

export class PreviewComponent implements OnInit {
public menus : any = [];
newuniq: any[][];

ngOnInit() {
 this.newmenuService.getProducts()
    .subscribe(resp=>{
      this.menus = resp;
    console.log("cart",this.menus)
    })
 const newuniq = [...new Set(this.menus.map(item => item.category
      ))];

 newuniq.forEach(function(element) {
      console.log("element",element);
      
    });

}

component.html {{newuniq}}

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

0

<div *ngFor="let item of newuniq">
{{item.category}}
</div>

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!