In my controller, I have data like:
$scope.object = data
Now this data is the dictionary with keys and values from json
.
I can access the attribute with object.name
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",
}
we can follow below procedure to avoid display of key-values in alphabetical order.
Javascript
HTML
You can do it in your javascript (controller) or in your html (angular view)...
js:
html:
I believe the html way is more angular , but you can also do in your controller and retrieve it in your html...
also not a bad idea to look at the Object keys, they give you the an array of the keys if you need them, more info here:
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
How about:
This method is listed in the docs: https://docs.angularjs.org/api/ng/directive/ngRepeat