0

I have an angular app in which i am creating a table based on the json as follows:

<thead>
  <tr>
    <th ng-repeat="(header, value) in resultData[0]">
      {{header}}
    </th>
  </tr>
</thead>

<tbody>
  <tr ng-repeat="row in resultData">
    <td ng-repeat="cell in row">
      {{cell}}
    </td>
  </tr>
</tbody>

Here the table creates the headings as well as the content from a json. But the result of this code is a table with sorted headings. Is there a way to keep the order the same as in the json file?

Abhishek
  • 2,998
  • 9
  • 42
  • 93

1 Answers1

0

Your headers are in an object. JavaScript objects do not guarantee property order. See this question. To preserve order, you have to use an array in your JSON file.

Community
  • 1
  • 1
Hugo Wood
  • 2,140
  • 15
  • 19