I have a list of data which when I make the bind I have to call a funcion on keypress event of input (I made my code in angular with this fiddle):
HTML
<div ng-app>
<div ng-controller="Ctrl">
<ul>
<li ng-repeat="item in Data">
<input ng-model="item.Value" ng-keydown="Total()" />
</li>
</ul>
Total: {{TheTotal}}
</div>
</div>
ANGULAR
function Ctrl($scope) {
$scope.Data = [
{
Value: 1
},
{
Value: 2
}];
$scope.TheTotal= 0;
$scope.Total = function()
{
var returnValue = 0;
$scope.TheTotal = 0;
for(var i = 0; i < $scope.Data.length; i++)
{
returnValue = returnValue + parseInt($scope.Data[i].Value);
}
$scope.TheTotal = returnValue;
};
}
But what I need is when the value of input changes, then makes the summatory but it is failing because always lost the last key pressed ... Any help ??
Here is the fiddler: Fiddler