A
A
Aidar2016-06-23 18:35:49
Angular
Aidar, 2016-06-23 18:35:49

How to add total sum incrementally in angular?

Hello! There is a form where values ​​are selected through selects and the whole thing adds up to the result. The choice of each select counts its own separate function i.e. in the end, I add up like this:
{{count() * total() + pol() + hard()}}
As a result, if a value is selected for all selects, then the total amount is calculated. But if, for example, no value is selected in hard(), then there will be no response. For example, I want to know at the moment the number multiplied by the total count() and total() , but I won’t get an answer. "pol()" and "hard()" are not selected.
Do not scold if clumsily described the problem .... with angular not so long ago. Who understood the problem, strike something.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aidar, 2016-06-24
@Aderus

Alexey Yarkov , thank you! You gave me an idea. I did this .... now all the values ​​​​of my selects are 0 by default. As a result, such code now counts even when I remove the select from pol ()

$scope.value = 0; 
$scope.pol = function () {    
   var res = $scope.value;
   return res;   
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question