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

93
Views
how to loop inside object array Angular

I want to display values from my json but I don't know how to do it. Is it possible to loop inside an object array ? i don't know if the keyvalue pipe can help me but I want to do without.

how to get the student2 and also the name to display it ?

thanks everyone.

json

{
 "student": {
   "student1": [],
   "student2": [
    {
      "id": "123",
      "name": "boot"
    },
    "student3": [],
   ]
  },
 "teacher": {
   "teacher1": [],
   "teacher2": [
    {
      "id": "123456",
      "name": "toto"
    },
   ]
  }
}

ts.file

get(){
 this.service.getAll().subscribe((data:any) => {
  object.keys(data).length > 0;
 })
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Assuming your JSON object from your GET request looks like the one you posted above simply do:

get(){
 this.service.getAll().subscribe((data:any) => {
  data.student.forEach(element => {
    for (let key in element) {
        console.log("      key:", key, "value:", element[key]);
        for (let val in element[key]) {
            console.log("      value:", val);
        }
    }
  });
 })
}
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!