0

I have nested JSON objects. I want to show nested data along with the main item but it's not showing the values.

ts code

  productAttributeItems: any[] = [];

    getProductAttributeItems() {
     this.productAttributeItems = this.productAttributeItems.filter(b => b.ProductId == 5);

     this.productService.getProductAttributesItems(5).subscribe(x => {
      Object.assign(this.productAttributeItems, x);
      console.log(x);
    });
  } 

Html

  <table class="table table-hover">
                  <thead>
                    <tr>
                      <th>Attribute Name</th>
                      <th>Name</th>
                      <th>Price</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr *ngFor="let attItems of productAttributeItems">
                      <td>{{ attItems.Name }}</td>
                      <td>{{ attItems.ProductAttributeItems?.MasterProductAttributeItem?.Name }}</td>
                      <td style="width: 40%; white-space: nowrap">{{ attItems.ProductAttributeItems.PriceAdjustment }}</td>
                    </tr>
                  </tbody>
</table> 

JSON DATA LINK

1 Answer 1

0

You can use console log to know deep and visualize structure of productAttributeItems

This is I tried to reproduce your JSON object structure.

<table class="table table-hover">
  <thead>
    <tr>
      <th>Attribute Name</th>
      <th>Name</th>
      <th>Price</th>
    </tr>
  </thead>
  <tbody>
    <tr *ngFor="let attItems of productAttributeItems.ProductAttributeItems">
      <td>{{ attItems?.MasterProductAttributeItem?.Name }}</td>
      <td>
        {{ productAttributeItems?.Name }}
      </td>
      <td style="width: 40%; white-space: nowrap">
        {{ attItems.PriceAdjustment }}
      </td>
    </tr>
  </tbody>
</table>

Link demo https://stackblitz.com/edit/angular-ivy-zh9spo

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.