Tahreem Iqbal Tahreem Iqbal - 3 months ago 11
JSON Question

Populate table with JSON list without knowing what the properties are

I'm receiving a

JSON
list from server that could contain any number of properties of any name. I need to show that list on my page. Populating a table when you know the names of properties is easy, but for this one I'm totally lost. Any help would be appreciated.

Answer

You can do this,

HTML:

 <table>
    <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>
  </table>

Here is a sample