I am aiming to create a table using AngularJS based on the nested JSON data provided below. The desired table format is outlined as follows:
{
"traits": ["Number of Observations","Observed Number of Exceptions","95-99", "95-95","99-95", "99-99"],
"values": [
{
"AAAA1": {
"Number of Observations": 252,
"95-95": {
"Test Statistic": -1.040531963428947,
"P-Value": 0.85095358899764695,
"Test Outcome": "p-value >=0.05"
},
"95-99": {
"Test Statistic": 5.368809379876272,
"P-Value": 3.9629067916102656e-08,
"Test Outcome": "p-value <0.01"
},
"Observed Number of Exceptions": 9
}
},
{
"AAAA2": {
"Number of Observations": 43,
"95-99": {
"Test Statistic": -1.040531963428947,
"P-Value": 0.85095358899764695,
"Test Outcome": "p-value >=0.05"
},
"95-95": {
"Test Statistic": -0.46245865041286727,
"P-Value": 0.67812377583172401,
"Test Outcome": "p-value >=0.05"
},
"Observed Number of Exceptions": 7
}
}
]
}
https://i.sstatic.net/U0NZ9.png
Under the 'values' key, there are two objects that will translate into two rows in the table. My issue lies with looping through objects like '95-95', '95-99', etc., and generating three columns for each object. Currently, I have managed to create three columns under the '95-95' object; however, I hard-coded the 'AAAA1' key value in ng-repeat
. I am struggling to dynamically access the middle-level Object key value not within any ng-repeat
. Is there a way to achieve this?
<tr ng-repeat="(key,value) in Controller.values">
<td class="text-center" ng-repeat="(key1,value1) in value['AAAA1']['95-95']">
{{value1}}
</td>
Due to this challenge, I am currently relying on the static code below which does not serve my needs effectively.
<td class="text-center" ng-repeat="(key1,value1) in value">
{{value1["95-95"]["Test Statistic"]}}
</td>
<td class="text-center" ng-repeat="(key1,value1) in value">
{{value1["95-95"]["P-Value"]}}
</td>
<td class="text-center" ng-repeat="(key1,value1) in value">
{{value1["95-95"]["Test Outcome"]}}
</td>