From a web service I am getting a JSON string. It may vary based on the request. 2 JSON result are
Result 1
[
{
"Key": 1,
"ID": 1,
"applicationId": "1",
"applicationName": "APP1"
},
{
"Key": 2,
"ID": 1,
"applicationId": "2",
"applicationName": "APP2"
}
]
Result 2
[
{
"OrgKey": 1,
"ID": 1,
"OrgID": "1",
"OrgName": "Org1"
},
{
"OrgKey": 2,
"ID": 4,
"OrgID": "6",
"OrgName": "Org2"
}
]
How will I display this in a table?
In controller js file I use the $http.get
method and in Success method I put
$scope.resultData = data;
But in HTML how I will display the dynamic contents?
<table>
<thead>
<tr>
<th ng-repeat = "result in resultData">
<!-- Not the right way -->
<!-- Here I want to put the headers like "Key,ID" ... -->
</th>
</tr> </thead>
<tbody>
<tr ng-repeat = ""result in resultData">
<td> {{result.Key }} </td>
<!-- When the firlds vary, how to put? ->
</tr>
</tbody>
</table>
Is it possible? If so How? Thanks.
$http.get
by right way (async call). Otherwise, HTML will show nothing. – Maxim Shoustin Apr 5 '14 at 7:30