0

I need to display a table using Angular ng-repeat but I don't know it's keys in advance.

Like, the response of API is Array of Objects

And, each Object has unknown keys.

enter image description here

In my HTML, I am doing ng-repeat over responseData.data.rows

<table id="customers">
  <tr ng-repeat = "x in myCtrl.demoDetails">

  </tr>
</table>

But how would I print values in table?

1
  • Please have a look here Object.keys. You can make use of Object.keys but that has limitations with angularjs. Check the answer for better understanding Commented Dec 12, 2018 at 10:44

1 Answer 1

2

It should look something like below,

<table class="table">
  <tr>
    <td>Task Name</td>
    <td>End Date</td>
    <td>Service Key</td>
  </tr>
<tr ng-repeat="x in responseData.data.rows">
  <td>{{x.task_name}}</td>
  <td>{{x.end_date}}</td>
  <td>{{x.service_key}}</td> 
</tr>
</table>
Sign up to request clarification or add additional context in comments.

3 Comments

you mean {{x.task_name}}
@Sajeetharan precisely the issue is I don't know in advance whether it would be task_name or something else? In this case it is task_name,end_date in other cases it oculd be something else

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.