0

I have a locally stored JSON file which then has a service which send through the following data set

[  
   {  
      "id":"73c624c9-6db7-4fd2-ac91-c1084aee0565",
      "etl":362,
      "subject":"Temp Subject",
      "body":"Temp Body",
      "deliveryAddress":"[email protected]",
      "accountNumber":"12345",
      "deliveryChannel":"EMAIL",
      "attachments":[  
         {  
            "id":"1",
            "attachToDeliveryMessage":false,
            "fileName":"12345-ITM-2019-01-25.pdf",
            "passwordProtected":true,
            "attachmentType":"ITEMISED_BILLING",
            "renderSucceeded":true,
            "renderError":null,
            "link":{  
               "href":"linky"
            }
         },
         {  
            "id":"2",
            "attachToDeliveryMessage":true,
            "fileName":"12345-INV-27608011279-2019-01-25.pdf",
            "passwordProtected":true,
            "attachmentType":"INVOICE",
            "renderSucceeded":true,
            "renderError":null,
            "link":{  
               "href":"linky"
            }
         }
      ],
      "renderSucceeded":true,
      "renderError":null
   },
]

I can successfully display the outer values but am having difficulty in displaying the nested values like "attachments"

Here is my HTML

<div class="card-body" *ngFor="let item of customerAccountDocs">
  <p>{{item.id}}</p>
  <p>{{item.accountNumber}}
  <p>{{item.etl}}
  <p>{{item.subject}}
  <p>{{item.body}}
  <p>{{item.deliveryAddress}}
  <p>{{item.deliveryChannel}}
  <p *ngFor="let item of customerAccountDocs.attachments">{{item.id}}</p>
</div>

Please assist me. I am just using bootstrap to display the data.

1 Answer 1

2

You should be iterating over item.attachments instead of customerAccountDocs.attachments

<div class="card-body" *ngFor="let item of customerAccountDocs">
  <p>{{item.id}}</p>
  <p>{{item.accountNumber}}
  <p>{{item.etl}}
  <p>{{item.subject}}
  <p>{{item.body}}
  <p>{{item.deliveryAddress}}
  <p>{{item.deliveryChannel}}
  <p *ngFor="let attachment of item.attachments">{{attachment.id}}</p>
</div>
Sign up to request clarification or add additional context in comments.

Comments

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.