Answer the question
In order to leave comments, you need to log in
How to add the entered numbers?
I am writing a budget calculation application, how to implement the output of the sum of entered numbers?
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>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question