NG-REPEAT inside NG-REPEAT - ANGULARJS

Asked

Viewed 668 times

1

I have a multidimensional array.

To demonstrate it in my view I use an ng-repeat in a ul inside another ng-repeat in a li, thus:

<ul ng-repeat="section in sections">
  <li>
      {{section.name}}
  </li>
  <ul>
    <li ng-repeat="tutorial in section.tutorials">
          {{tutorial.name}}
    </li>
  </ul>
</ul>

How could I demonstrate these values in a table? Since it’s not possible this way:

  <tr ng-repeat="section in sections">
    <tr ng-repeat="tutorial in section.tutorials"> 
      <td>{{:: tutorial.name }}</td>
    </tr>
  </tr>

2 answers

0


I ended up being able to solve using ng-repeat-start and ng-repeat-end. Follow:

<table>
  <tbody>
  <tr ng-repeat="section in sections">
    <td ng-repeat-start="tutorial in section.tutorials">{{:: tutorial.name }}</td>
    <td ng-repeat-end>{{:: tutorial.autor }}</td>
  </tr>
  </tbody>
</table>

0

try this

<tr ng-repeat="tutorial  in tutorials| filterData: 'sections'">
   <td>{{tutorial.name}}</td>
</tr>

or use tbody

<table>
  <tbody ng-repeat="section in sections">
  <tr ng-repeat="tutorial in section.tutorials">
    <td>{{:: tutorial.name }}</td>
  </tr>
  </tbody>
</table>
  • It didn’t work out either way :(

  • You could post your json structure of the sections object?

  • I got it! haha, I’ll post it here..

Browser other questions tagged

You are not signed in. Login or sign up in order to post.