How can get name of children in array with angular Iuse ngfor and father name and child id but unable to get childern name | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can get name of children in array with angular Iuse ngfor and father name and child id but unable to get childern name

People = [{id : 1, name: "barun", children:[2]}, {id:2, name:"rahul", children:[3,4]},{id:3,name:"asif"},{id:4,name:"chetan"}] *ngFor ="let person of people" <> *ngFor = "let child of person.children" {{person.name}} and {{child}}

7th Jan 2020, 1:38 PM
Rahul Gandhi
Rahul Gandhi - avatar
1 Answer
0
You can refer following code: <div *ngFor="let item of People"> <ul > <li>{{item.name}}</li> <ul *ngFor="let obj of item.children"> {{obj}} </ul> </ul> </div>
17th Mar 2020, 4:27 AM
Ishan Shah
Ishan Shah - avatar