-2

I am trying to get angular to display some data.

Here is the data:

data = [
   {
      title: 'title1',
      data: [
         {
            id: 1,
            description: 'some description'
         },
         {
            id: 2,
            description: 'some other description'
         }
      ]
   },
   {
      title: 'title2',
      data: [
         {
            id: 1,
            description: 'some description'
         },
         {
            id: 2,
            description: 'some other description'
         }
       ]
    }
 ]

And here is the code I'm trying:

<div *ngFor="let item of data">
   <div>{{ item.title }}</div>
   <ul>
      <li>item.data.description</li>
   </ul>
</div>

The data.description's are not showing.

How can I get it to display all the data?

0

1 Answer 1

1

data is an array. You need a second *ngFor-block for the data.

  <div *ngFor="let item of data">
    <div>{{ item.title }}</div>
    <ul *ngFor="let itemsdata of item.data">
        <li>itemsdata.description</li>
    </ul>
  </div>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.