1

I am displaying data using below Json. it's working fine up-to two array while displaying third inner array i am getting error.kindly please suggest me how can successfully retrieve it.

<tr *ngFor="let priceRowData of solutionData.groups.requestDetails ;let $index=index ">
   <td>{{priceRowData.ReqId}}</td>
</tr>

New Json : solutiondetail -> groups - > request details

 {
        "SolutionsDetail": [
            {
                "SolutionId": 658,
                "name": "dk",
                "id": 1568377327000,
                "groups": [
                    {
                        "GroupId": 1,
                        "requestDetails": [
                            {
                                "ReqId": 2331,

                            },

                        ]
                    }

                ]
            }
        ]
    }

I just want to display all request-details id into UI. How can i achieve that here.

1 Answer 1

1

You can access array's element directly through property access. Since there are three nested array's, you have to loop all those array's to get access to their properties. So you will have to use 3 nested ngFor directive to list down all elements dynamically.

Html

<tr *ngFor="let priceRowData of SolutionsDetail">
  <ng-container *ngFor="let group of priceRowData.groups">
     <ng-container *ngFor="let requestDetail of group.requestDetails">
       <td>{{requestDetail.ReqId}}</td>
     </ng-container>
  </ng-container>
</tr>

Stackblitz

Sign up to request clarification or add additional context in comments.

2 Comments

i 'm getting this ERROR TypeError: Cannot read property 'length' of undefined
@DharamChauhan sounds like one of the variables/properties that you think holds an array is actually undefined. Alternatively, one of the variables/properties is being changed to undefined while your app is running.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.