user192362127 user192362127 - 1 year ago 79
AngularJS Question

How can I iterate over the keys, value in ng-repeat in angular

In my controller, I have data like:

$scope.object = data

Now this data is the dictionary with keys and values from

I can access the attribute with
in the template. Is there any way that I can iterate over the keys as well and display them in table like

<tr><td> {{key}} </td> <td> data.key </td>

The data is like this

"id": 2,
"project": "wewe2012",
"date": "2013-02-26",
"description": "ewew",
"eet_no": "ewew",

Answer Source

How about:

<tr ng-repeat="(key, value) in data">
  <td> {{key}} </td> <td> {{ value }} </td>

This method is listed in the docs: