I am writing an application for calculating the budget, how to implement the output of the sum of the numbers entered?
function TodoCtrl($scope){ var sums = $scope.sums = []; $scope.sum = '200'; $scope.addSu = function(sum){ sums.push(sum); }; $scope.removeSum = function(index){ sum.splice(index,1); }; } <!DOCTYPE html> <html> <head> <script src="http://code.angularjs.org/1.1.4/angular.min.js"></script> <script src="todo.js"></script> </head> <body> <div ng-app> <div ng-controller="TodoCtrl"> <h2>Сегодня я потратил: {{sum}} руб.</h2> <input type = 'text' ng-model = "sum" size = "40" /> <button ng-click = "addSu(sum)">Добавить</button> <ul> <li ng-repeat = "sum in sums track by $index"> <span ng-bind="$parent.$eval(sum)"></span> <span>руб</span> </li> </ul> </div> </div> </body> </html>
evaloutside of directives - Grundy