After retrieving data from my web service, I am storing it in my scope
variable like this:
then(function (Tlist) {
$scope.Tlist=Tlist.data;
})
I then display this data in a table, where I can select rows using checkboxes:
<td>
<input type="checkbox" ng-checked="checkall" ng-model="Ldata.checked" data-ng-click="calculateTotal(Ldata)" />
</td>
In the "calculateTotal(Ldata)"
function, I need to store the value of (Ldata.amount)
in another $scope
variable.
This is what the condition inside the function looks like:
if (Ldata.checked) {
$scope.total += Number(Ldata.amount);
console.log(Ldata.amount);
console.log(Number($scope.total));
}
However, when I check on
console.log(Number($scope.total));
the result shows as NaN
. But on the line above and on the line with console.log(Ldata.amount);
, the result appears as 1400
. This discrepancy has me puzzled as to why I can't transfer data from one variable to another.