I am trying to create a function that sums some numbers from an incoming factory (and some from the client side in real time) and puts the amount in a view. Completely stuck.
1 - First of all, I donβt understand how to display in a view a variable that was assembled in a controller function.
So, let's say I have something like:
$scope.total = function() { var totalNumber = 0; }
How do I display totalNumber in a view?
I assume that after getting this, to summarize the factory:
var revenues = [ { amount: 1254 }, { amount: 1654 }, { amount: 33 }, { amount: 543 } ];
I will need to do something like:
$scope.total = function() { var totalNumber = 0; for(i=0; i<revenues.length; i++){ totalNumber = totalNumber + revenues[i].amount } }
It is right? Will it be updated in real time if I dynamically change the revenue array?
source share