I have a simple list of inputs bound to a list of items that display nicely. When I change a value in an input, the sum doesn't update??
Example: http://plnkr.co/edit/B7tEAsXSFvyLRmJ5xcnJ?p=preview
Html
<body ng-controller="MainCtrl">
<div ng-repeat="item in items">
<p><input type=text value="{{item}}"></p>
</div>
Total: <input type=text value="{{sum(items)}}">
</body>
Script
app.controller('MainCtrl', function($scope) {
$scope.items = [1,2,5,7];
$scope.sum = function(list) {
var total=0;
angular.forEach(list , function(item){
total+= item;
});
return total;
}
});