Yo everyone.
I've got a .json file structured like that :
var var1 =
[ { "a":"soluce1",
"b":
[ { "user1" : "username1",
"ba" : "1" },
{ "user2" : "username2",
"ba" : "2" } ],
"c":"useless"
} ];
, my .html file :
<tr ng-repeat="varhtml in var1">
<td>{{varhtml.b[0].ba}}</td>
</tr>
and it appears :
1
I know that all is good at first. For the next step, I would display
3
, result of (1+2
: (ba+ba
and more arrays if needed...)). At first glance I thought that was not really difficult but I don't know what I need to do with <td>{{varhtml.b[0].ba}}</td>
or others files to have this wish.
Thank you in advance for the helps.
WORKING RESULT :
$scope.additionNumber = function (varhtml) {
var total = 0;
angular.forEach (varhtml.b, function (ligne) {
total += ligne.ba;
});
return total;
}
<tr ng-repeat="varhtml in var1">
<td><span ng-bind="additionNumber(varhtml)"></span></td>
</tr>