So I made a simple JavaScript project using AngularJS,
Here's my controller
angular.module('myApp')
.controller('BillDetail3Ctrl', function ($scope, billDetail3) {
$scope.tableData = [];
$scope.hourCount = 0;
billDetail3.getMetList().then(function(data){
var no = 0;
for (var i = 0; i < data.length; i++) {
for (var j = 0; j == data[0].d.currA.length; j++) {
$scope.tableData.push({
'No': ++no,
'_id': data[i]._id,
'hourtag': data[i].d.hourtag,
'currA': data[i].d.currA[j]
});
}
}
$scope.hourCount = no;
}, function(){
});
});
Those controller was fetching data from this JSON: http://amr2.mybluemix.net/getmet/list This is the format of JSON:
[
{
"_id": "100010001_20082015_0",
"_rev": "8-e72619f2c6c05aac2e3692f1ea77eb0f",
"d": {
"uSN": "100010001",
"timetag": 20082015,
"hourtag": 0,
"currA": {
"0": 0,
"1": 2,
"2": 5,
"3": 6,
"4": 2.3
},
"currB": {
"0": 10,
"1": 23,
"2": 52,
"3": 61,
"4": 12.3
},
"currABC": {
"0": 0.1,
"1": 2.2,
"2": 5.2
},
Here's my view:
<tr ng-repeat="pop in tableData">
<td>{{pop.No}}</td>
<td>{{pop._id}}</td>
<td>{{pop.hourtag}}</td>
<td>{{pop.currA}}</td> //This is doesn't work
</tr>
But this code <td>{{pop.currA}}</td> doesn't work. So, in JSON I have hourtag = 0, hourtag = 1, etc. In each hourtag, I have "currA": { "0": x, "1" = x, etc. The idea was I want to call all of the currA value which is in the first "0" in every hourtag and put that in my table. How can I do that?
